@@ -4782,15 +4782,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
4782
4782
isAsymmetricDescriptor = true;
4783
4783
}
4784
4784
} else {
4785
- // Handle the special case of LiteralString.
4786
- if (
4787
- ClassType.isBuiltIn(baseType, 'LiteralString') &&
4788
- strClassType &&
4789
- isInstantiableClass(strClassType)
4790
- ) {
4791
- baseType = ClassType.cloneAsInstance(strClassType);
4792
- }
4793
-
4794
4785
// Handle the special case of 'name' and 'value' members within an enum.
4795
4786
const enumMemberResult = getTypeOfEnumMember(
4796
4787
evaluatorInterface,
@@ -11883,15 +11874,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
11883
11874
return subtype;
11884
11875
}
11885
11876
11886
- if (
11887
- isClassInstance(subtype) &&
11888
- ClassType.isBuiltIn(subtype, 'LiteralString') &&
11889
- strClassType &&
11890
- isInstantiableClass(strClassType)
11891
- ) {
11892
- return handleSubtype(ClassType.cloneAsInstance(strClassType));
11893
- }
11894
-
11895
11877
if (isClassInstance(subtype) || isInstantiableClass(subtype) || isTypeVar(subtype)) {
11896
11878
return handleSubtype(subtype);
11897
11879
}
@@ -14080,7 +14062,16 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
14080
14062
assert(isInstantiableClass(cachedType));
14081
14063
return cachedType as ClassType;
14082
14064
}
14065
+
14083
14066
const specialType = createSpecialBuiltInClass(node, assignedName, aliasMapEntry);
14067
+
14068
+ // Handle 'LiteralString' specially because we want it to act as
14069
+ // though it derives from 'str'.
14070
+ if (assignedName === 'LiteralString') {
14071
+ specialType.details.baseClasses.push(strClassType ?? AnyType.create());
14072
+ computeMroLinearization(specialType);
14073
+ }
14074
+
14084
14075
writeTypeCache(node, specialType, EvaluatorFlags.None, /* isIncomplete */ false);
14085
14076
return specialType;
14086
14077
}
@@ -21011,7 +21002,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
21011
21002
}
21012
21003
}
21013
21004
21014
- let concreteSrcType = makeTopLevelTypeVarsConcrete(srcType);
21005
+ const concreteSrcType = makeTopLevelTypeVarsConcrete(srcType);
21015
21006
if (isClass(concreteSrcType) && TypeBase.isInstance(concreteSrcType)) {
21016
21007
if (destType.literalValue !== undefined) {
21017
21008
const srcLiteral = concreteSrcType.literalValue;
@@ -21031,15 +21022,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
21031
21022
if (ClassType.isBuiltIn(destType, 'LiteralString')) {
21032
21023
if (ClassType.isBuiltIn(concreteSrcType, 'str') && concreteSrcType.literalValue !== undefined) {
21033
21024
return true;
21034
- } else if (ClassType.isBuiltIn(concreteSrcType, 'LiteralString')) {
21035
- return true;
21036
21025
}
21037
- } else if (
21038
- ClassType.isBuiltIn(concreteSrcType, 'LiteralString') &&
21039
- strClassType &&
21040
- isInstantiableClass(strClassType)
21041
- ) {
21042
- concreteSrcType = ClassType.cloneAsInstance(strClassType);
21043
21026
}
21044
21027
21045
21028
if (
0 commit comments