File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -4341,14 +4341,11 @@ def visit_index_with_type(
43414341 elif isinstance (left_type , FunctionLike ) and left_type .is_type_obj ():
43424342 if left_type .type_object ().is_enum :
43434343 return self .visit_enum_index_expr (left_type .type_object (), e .index , e )
4344- elif left_type .type_object ().type_vars and self .chk .options .python_version >= (3 , 9 ):
4345- return self .named_type ("types.GenericAlias" )
4346- elif (
4347- left_type .type_object ().fullname == "builtins.type"
4348- and self .chk .options .python_version >= (3 , 9 )
4344+ elif self .chk .options .python_version >= (3 , 9 ) and (
4345+ left_type .type_object ().type_vars
4346+ or left_type .type_object ().fullname == "builtins.type"
43494347 ):
4350- # builtins.type is special: it's not generic in stubs, but it supports indexing
4351- return self .named_type ("typing._SpecialForm" )
4348+ return self .named_type ("types.GenericAlias" )
43524349
43534350 if isinstance (left_type , TypeVarType ) and not self .has_member (
43544351 left_type .upper_bound , "__getitem__"
Original file line number Diff line number Diff line change @@ -1781,7 +1781,7 @@ C = str | int
17811781D: TypeAlias = str | int
17821782[out]
17831783_testTypeAliasNotSupportedWithNewStyleUnion.py:3: error: Invalid type alias: expression is not a valid type
1784- _testTypeAliasNotSupportedWithNewStyleUnion.py:3: error: Unsupported left operand type for | ("<typing special form> ")
1784+ _testTypeAliasNotSupportedWithNewStyleUnion.py:3: error: Unsupported left operand type for | ("GenericAlias ")
17851785_testTypeAliasNotSupportedWithNewStyleUnion.py:4: error: Invalid type alias: expression is not a valid type
17861786_testTypeAliasNotSupportedWithNewStyleUnion.py:4: error: Unsupported left operand type for | ("Type[str]")
17871787_testTypeAliasNotSupportedWithNewStyleUnion.py:5: error: Invalid type alias: expression is not a valid type
You can’t perform that action at this time.
0 commit comments