Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Disallow no-args generic aliases when using PEP 613 explicit aliases #18173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests for generic classes and tuple/callable special cases
  • Loading branch information
brianschubert committed Nov 21, 2024
commit d1c756bc5a8b93359f2b094e9edfeee293b65029
45 changes: 43 additions & 2 deletions 45 test-data/unit/check-type-aliases.test
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,8 @@ A = Union[int, List[A]]
def func(x: A) -> int: ...
[builtins fixtures/tuple.pyi]

[case testAliasExplicitNoArgsNotGeneric]
from typing import List, assert_type
[case testAliasExplicitNoArgsBasic]
from typing import Any, List, assert_type
from typing_extensions import TypeAlias

Implicit = List
Expand All @@ -1249,4 +1249,45 @@ Explicit: TypeAlias = List
x1: Implicit[str]
x2: Explicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
assert_type(x1, List[str])
assert_type(x2, List[Any])
[builtins fixtures/tuple.pyi]

[case testAliasExplicitNoArgsGenericClass]
# flags: --python-version 3.9
from typing import Any, assert_type
from typing_extensions import TypeAlias

Implicit = list
Explicit: TypeAlias = list

x1: Implicit[str]
x2: Explicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
assert_type(x1, list[str])
assert_type(x2, list[Any])
[builtins fixtures/tuple.pyi]

[case testAliasExplicitNoArgsTuple]
from typing import Any, Tuple, assert_type
from typing_extensions import TypeAlias

Implicit = Tuple
Explicit: TypeAlias = Tuple

x1: Implicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
x2: Explicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
assert_type(x1, Tuple[Any, ...])
assert_type(x2, Tuple[Any, ...])
[builtins fixtures/tuple.pyi]

[case testAliasExplicitNoArgsCallable]
from typing import Any, Callable, assert_type
from typing_extensions import TypeAlias

Implicit = Callable
Explicit: TypeAlias = Callable

x1: Implicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
x2: Explicit[str] # E: Bad number of arguments for type alias, expected 0, given 1
assert_type(x1, Callable[..., Any])
assert_type(x2, Callable[..., Any])
[builtins fixtures/tuple.pyi]
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.