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

Support flake8-pep585 for accesses from typing after import #3936

Open
wookie184 opened this issue Apr 11, 2023 · 1 comment · May be fixed by #5454
Open

Support flake8-pep585 for accesses from typing after import #3936

wookie184 opened this issue Apr 11, 2023 · 1 comment · May be fixed by #5454
Labels
rule Implementing or modifying a lint rule

Comments

@wookie184
Copy link
Contributor

Ruff catches all of these as UP035 violations:

from typing import (
    Container,
    Callable,
    AsyncIterable,
    Mapping,
    Coroutine,
    OrderedDict,
)

However, none of these trigger that rule:

import typing

a: typing.Container
b: typing.Callable
c: typing.AsyncIterable
d: typing.Mapping
e: typing.Coroutine
f: typing.OrderedDict

This isn't something supported by pyupgrade (as the autofix would be quite complicated), but it seems like it would be worth a warning. flake8-pep585 catches these.

On ruff playground:
https://play.ruff.rs/#N4KABGBEDOCmA2sDGAXSAuMBtSBVACpALoA04UKAhgE4DmsKAtAG6zXQCWA9gHYZQAHAJ4BmAIxjIIAL4ASeRwC2ArtRRgUQgRx60QISpk3bdAOgDCvKjrYgARka07aFyvHiU7iEEkcmXAILQQjxIAJIobJ7eACZ+zqYAspQC-iCw8WaW1FwArig2IABmmS4A8tQxbLAxACIcqPpFOYoaTrpgSipqYAAU5BCWPNY8bGQQg24eXrDjE0Eh4ZHU0bMDYMmpznODqnkFoztgFVXUNfWoZACUQA

Note that the names I listed are just examples, there are probably more pep 585 names with the same issue.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Apr 11, 2023
@charliermarsh
Copy link
Member

I agree that we should flag these. They can probably go under the existing pyupgrade rules (even if we can't fix them right now). We do have most of the machinery we'd need to fix these, but that can be a separate effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants