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

False negative: Use of variable in type expression is not reported if its type is a TypeVar or Self #9750

Open
erictraut opened this issue Jan 23, 2025 · 0 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working spec compliance

Comments

@erictraut
Copy link
Collaborator

The typing spec says that variables cannot be used within type expressions, but pyright fails to report an error in some cases.

class A:
    @classmethod
    def m1(cls):
        a: cls

    def m2(self):
        a: self

By contrast, mypy correctly flags these errors.

@erictraut erictraut added bug Something isn't working spec compliance labels Jan 23, 2025
erictraut added a commit that referenced this issue Jan 23, 2025
…hin a type expression and the parameter's type is a TypeVar or Self. This addresses #9750.
erictraut added a commit that referenced this issue Jan 23, 2025
…hin a type expression and the parameter's type is a TypeVar or Self. This addresses #9750. (#9751)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working spec compliance
Projects
None yet
Development

No branches or pull requests

1 participant