More precise type for TypeAliasType.__getitem__ (#12354)

At runtime, this always returns a GenericAlias; see typealias_subscript
in Objects/typevarobject.c. See microsoft/pyright#8444.
This commit is contained in:
Jelle Zijlstra
2024-07-17 06:37:31 -07:00
committed by GitHub
parent 6d68b57d74
commit d482d4e83c
2 changed files with 2 additions and 1 deletions

View File

@@ -403,6 +403,7 @@ else:
# It's writable on types, but not on instances of TypeAliasType.
@property
def __module__(self) -> str | None: ... # type: ignore[override]
# Returns typing._GenericAlias, which isn't stubbed.
def __getitem__(self, parameters: Any) -> Any: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ...