@zzzen/pyright-internal 1.2.0-dev.20241027 → 1.2.0-dev.20241103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/binder.d.ts +1 -3
- package/dist/analyzer/binder.js +1 -9
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +9 -5
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +2 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +18 -1
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +1 -1
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +1 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/enums.js +3 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +2 -0
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +1 -1
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/protocols.js +1 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/sourceFile.js +1 -1
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +2 -2
- package/dist/analyzer/typeEvaluator.js +108 -31
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +10 -5
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +6 -0
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +0 -1
- package/dist/analyzer/typeUtils.js +42 -23
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +2 -1
- package/dist/analyzer/typedDicts.js +21 -1
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.js +4 -5
- package/dist/analyzer/types.js.map +1 -1
- package/dist/languageService/completionProvider.js +1 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +2 -1
- package/dist/languageService/hoverProvider.js +33 -10
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/tests/fourslash/hover.typedDict.get.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.typedDict.get.fourslash.js +16 -0
- package/dist/tests/fourslash/hover.typedDict.get.fourslash.js.map +1 -0
- package/dist/tests/typeEvaluator2.test.js +4 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +6 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +6 -0
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +10 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +4 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/package.json +1 -1
@@ -893,6 +893,9 @@ function selfSpecializeClass(type, options) {
|
|
893
893
|
return type;
|
894
894
|
}
|
895
895
|
const typeParams = type.shared.typeParams.map((typeParam) => {
|
896
|
+
if ((0, types_1.isTypeVarTuple)(typeParam)) {
|
897
|
+
typeParam = types_1.TypeVarType.cloneForUnpacked(typeParam);
|
898
|
+
}
|
896
899
|
return (options === null || options === void 0 ? void 0 : options.useBoundTypeVars) ? types_1.TypeVarType.cloneAsBound(typeParam) : typeParam;
|
897
900
|
});
|
898
901
|
return types_1.ClassType.specialize(type, typeParams);
|
@@ -1331,7 +1334,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* MemberAcces
|
|
1331
1334
|
let classFlags = 0 /* ClassIteratorFlags.Default */;
|
1332
1335
|
if (flags & 1 /* MemberAccessFlags.SkipOriginalClass */) {
|
1333
1336
|
if ((0, types_1.isClass)(classType)) {
|
1334
|
-
skipMroClass = classType;
|
1337
|
+
skipMroClass = (0, types_1.isClassInstance)(classType) ? types_1.ClassType.cloneAsInstantiable(classType) : classType;
|
1335
1338
|
}
|
1336
1339
|
}
|
1337
1340
|
if (flags & 2 /* MemberAccessFlags.SkipBaseClasses */) {
|
@@ -1418,7 +1421,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* MemberAcces
|
|
1418
1421
|
// Handle the special case of a __call__ class member in a partial class.
|
1419
1422
|
if (memberName === '__call__' &&
|
1420
1423
|
classType.priv.partialCallType &&
|
1421
|
-
types_1.ClassType.isSameGenericClass(classType, specializedMroClass)) {
|
1424
|
+
types_1.ClassType.isSameGenericClass(types_1.TypeBase.isInstance(classType) ? types_1.ClassType.cloneAsInstantiable(classType) : classType, specializedMroClass)) {
|
1422
1425
|
symbol = symbol_1.Symbol.createWithType(4 /* SymbolFlags.ClassMember */, classType.priv.partialCallType);
|
1423
1426
|
}
|
1424
1427
|
const cm = {
|
@@ -1592,6 +1595,10 @@ function getTypeVarArgsRecursive(type, recursionCount = 0) {
|
|
1592
1595
|
if (type.shared.recursiveAlias) {
|
1593
1596
|
return [];
|
1594
1597
|
}
|
1598
|
+
// Don't return any bound type variables.
|
1599
|
+
if (types_1.TypeVarType.isBound(type)) {
|
1600
|
+
return [];
|
1601
|
+
}
|
1595
1602
|
// Don't return any P.args or P.kwargs types.
|
1596
1603
|
if ((0, types_1.isParamSpec)(type) && type.priv.paramSpecAccess) {
|
1597
1604
|
return [types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined)];
|
@@ -3300,32 +3307,44 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3300
3307
|
return getUnknownForTypeVar(typeVar, (_c = this._options.replaceUnsolved) === null || _c === void 0 ? void 0 : _c.tupleClassType);
|
3301
3308
|
}
|
3302
3309
|
transformUnionSubtype(preTransform, postTransform) {
|
3303
|
-
var _a, _b;
|
3310
|
+
var _a, _b, _c;
|
3304
3311
|
// If a union contains unsolved TypeVars within scope, eliminate them
|
3305
3312
|
// unless this results in an empty union. This elimination is needed
|
3306
3313
|
// in cases where TypeVars can go unsolved due to unions in parameter
|
3307
3314
|
// annotations, like this:
|
3308
3315
|
// def test(x: Union[str, T]) -> Union[str, T]
|
3309
|
-
if ((_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.eliminateUnsolvedInUnions) {
|
3310
|
-
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3316
|
+
if (!((_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.eliminateUnsolvedInUnions)) {
|
3317
|
+
return postTransform;
|
3318
|
+
}
|
3319
|
+
const solutionSet = this._solution.getSolutionSet((_b = this._activeConstraintSetIndex) !== null && _b !== void 0 ? _b : 0);
|
3320
|
+
if ((0, types_1.isTypeVar)(preTransform)) {
|
3321
|
+
if (!this._shouldReplaceTypeVar(preTransform) || !this._shouldReplaceUnsolvedTypeVar(preTransform)) {
|
3322
|
+
return postTransform;
|
3323
|
+
}
|
3324
|
+
const typeVarType = solutionSet.getType(preTransform);
|
3325
|
+
// Did the TypeVar remain unsolved?
|
3326
|
+
if (typeVarType) {
|
3327
|
+
if (!(0, types_1.isTypeVar)(typeVarType) || !types_1.TypeVarType.isUnification(typeVarType)) {
|
3328
|
+
return postTransform;
|
3329
|
+
}
|
3330
|
+
}
|
3331
|
+
// If the TypeVar was not transformed, then it was unsolved,
|
3332
|
+
// and we'll eliminate it.
|
3333
|
+
if (preTransform === postTransform) {
|
3334
|
+
return undefined;
|
3335
|
+
}
|
3336
|
+
// If useDefaultForUnsolved or useUnknownForUnsolved is true, the postTransform type will
|
3337
|
+
// be Unknown, which we want to eliminate.
|
3338
|
+
if (this._options.replaceUnsolved && (0, types_1.isUnknown)(postTransform)) {
|
3339
|
+
return undefined;
|
3340
|
+
}
|
3341
|
+
}
|
3342
|
+
else if ((_c = preTransform.props) === null || _c === void 0 ? void 0 : _c.condition) {
|
3343
|
+
// If this is a type that is conditioned on a unification TypeVar,
|
3344
|
+
// see if TypeVar was solved. If not, eliminate the type.
|
3345
|
+
for (const condition of preTransform.props.condition) {
|
3346
|
+
if (types_1.TypeVarType.isUnification(condition.typeVar) && !solutionSet.getType(condition.typeVar)) {
|
3347
|
+
return undefined;
|
3329
3348
|
}
|
3330
3349
|
}
|
3331
3350
|
}
|