-
-
Notifications
You must be signed in to change notification settings - Fork 394
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
Do not allow TypeVarTuple
after TypeVar
with a default
#3265
Comments
Hi. I want to address this issue. Did some research on it. I think the solution is as follows:
However, there are some questions:
|
We should only check for pep695 definitions. No imports. No global variables. |
Given an example: from typing import TypeVar
class MyClass[T]:
V = TypeVar("V", default=int)
def method(self, v: V) -> V:
...
# V is accessible here
# but not here Should we forget about V's existence after the class declaration, or pretend it's defined at the top level? The first approach is more correct, but the second one is easier to implement |
We only care about pep695 types here, no other cases :) |
Where the rule should go? Into OOP or into Best practices section? |
…thDefaultViolation and corresponding tests
There's a pattern that is allowed from typing perspective:
https://mypy-play.net/?mypy=latest&python=3.13&gist=cbd582efc127e91a38a022d99ea7269f
But, it is a really bad pattern, because you cannot specify
*Ts
without specifingT
So, we need to find
type_params
definitions whereTypeVar
with default is followed byTypeVarTuple
with default.The text was updated successfully, but these errors were encountered: