Skip to content
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

Fix disallow-any errors for Instance types (PEP 696) #16832

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 28, 2024

Similar to TypeAlias types Missing type parameters for generic type should not be emitted if too many arguments are given. There is a separate error message for that.

Ref: #14851

This comment has been minimized.

@cdce8p cdce8p force-pushed the TypeVar-07-fix-disallow-any branch from 2b21ed3 to 308e87a Compare January 31, 2024 16:12
@cdce8p
Copy link
Collaborator Author

cdce8p commented Jan 31, 2024

/CC @JelleZijlstra

@@ -315,7 +318,7 @@ def func_c3(
class ClassC4(Generic[T1, Unpack[Ts1], T3]): ...

def func_c4(
a: ClassC4,
a: ClassC4, # E: Missing type parameters for generic type "ClassC4[()]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the [()] part?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted the type formatting to better handle this case. It was just checking if the instance has a TypeVarTuple and assumed that it's the only TypeVar -> thus printing () for an empty tuple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This comment has been minimized.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@cdce8p cdce8p added the topic-pep-696 TypeVar defaults label Jan 31, 2024
@JelleZijlstra JelleZijlstra merged commit c3cd83a into python:master Jan 31, 2024
18 checks passed
@cdce8p cdce8p deleted the TypeVar-07-fix-disallow-any branch January 31, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-pep-696 TypeVar defaults
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants