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

UP006 does not report type annotations in quotes #3555

Closed
roikoren755 opened this issue Mar 16, 2023 · 2 comments · Fixed by #3593
Closed

UP006 does not report type annotations in quotes #3555

roikoren755 opened this issue Mar 16, 2023 · 2 comments · Fixed by #3593
Assignees
Labels
bug Something isn't working

Comments

@roikoren755
Copy link

First of all, thank you so much for a great linter! We recently moved from flake8 to ruff, which massively sped up our linting step, and allowed us to check for things we couldn't previously use flake8 plugins for, like flake8-type-checking, due to having to support Python 3.6. This just worked with ruff, without any hassle! 👏

We recently updated one of our repositories to a newer version of Python, and wanted to turn on UP006, specifically, when we ran into what we believe is a bug.
If the typing annotation that includes a generic from typing that is no longer necessary, according to PEP585, the UP006 rule does not flag it as an error.

from typing import Dict

does_not_flag: "Dict[str, str]" = {}
does_flag: Dict[str, str] = {}

The command used to run is ruff check up006.py --isolated --select UP006, and the output of ruff --version is ruff 0.0.256.

Once again, thanks for all your work!

@charliermarsh
Copy link
Member

Thanks for the kind words :)

I think we can check and fix these but I need to do some research -- there are some unintuitive corner cases around quoted annotations. We should almost certainly be flagging them as errors though, even if we can't autofix them.

(Related to #3508.)

@charliermarsh
Copy link
Member

For now, made sure that we flag these. In the future, we'll be able to autofix some cases, but not all (e.g., this is valid, but hard to fix: x: "Li" "st[int] = []).

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