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 positive: PYI015 does not allow assigning typing_extensions.TypeVar #3950

Closed
bryanforbes opened this issue Apr 12, 2023 · 2 comments · Fixed by #3951
Closed

False positive: PYI015 does not allow assigning typing_extensions.TypeVar #3950

bryanforbes opened this issue Apr 12, 2023 · 2 comments · Fixed by #3951
Assignees
Labels
bug Something isn't working

Comments

@bryanforbes
Copy link

Ruff version: 0.0.261

Given the following file test.pyi:

from typing_extensions import TypeVar

_T = TypeVar('_T', infer_variance=True)

And the following invocation:

ruff --select PYI015 --isolated --no-cache test.pyi

Ruff produces the following error:

test.pyi:3:6: PYI015 [*] Only simple default values allowed for assignments

PEP-695 and PEP-696 are under consideration and add new parameters to TypeVar(). typing_extensions has added a TypeVar class in order to test out these new features before they are accepted. flake8-pyi does not raise Y015 for the above.

@charliermarsh charliermarsh added the bug Something isn't working label Apr 12, 2023
@charliermarsh charliermarsh self-assigned this Apr 12, 2023
@charliermarsh
Copy link
Member

It looks like we allow from typing import TypeVar here but not from typing_extensions import TypeVar. I think it's just an oversight. Will double check.

@bryanforbes
Copy link
Author

bryanforbes commented Apr 12, 2023

It looks like flake8-pyi checks for both typing and typing_extensions here: https://github.com/PyCQA/flake8-pyi/blob/64863f80c7f91fae23418db048bb41185c2fb5ed/pyi.py#L354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants