File tree 2 files changed +5
-8
lines changed
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(
4341
4341
elif isinstance (left_type , FunctionLike ) and left_type .is_type_obj ():
4342
4342
if left_type .type_object ().is_enum :
4343
4343
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"
4349
4347
):
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" )
4352
4349
4353
4350
if isinstance (left_type , TypeVarType ) and not self .has_member (
4354
4351
left_type .upper_bound , "__getitem__"
Original file line number Diff line number Diff line change @@ -1781,7 +1781,7 @@ C = str | int
1781
1781
D: TypeAlias = str | int
1782
1782
[out]
1783
1783
_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 ")
1785
1785
_testTypeAliasNotSupportedWithNewStyleUnion.py:4: error: Invalid type alias: expression is not a valid type
1786
1786
_testTypeAliasNotSupportedWithNewStyleUnion.py:4: error: Unsupported left operand type for | ("Type[str]")
1787
1787
_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