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

Mark quotes as unnecessary for non-evaluated annotations #11485

Merged
merged 1 commit into from
May 22, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented May 21, 2024

Summary

Similar to #11414, this PR extends UP037 to flag quoted annotations that are located in positions that won't be evaluated at runtime.

For example, the quotes on Tuple are unnecessary in:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import Tuple


def foo():
    x: "Tuple[int, int]" = (0, 0)

foo()
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label May 21, 2024
@charliermarsh charliermarsh merged commit 519a650 into main May 22, 2024
18 of 19 checks passed
@charliermarsh charliermarsh deleted the charlie/runtime-annotations branch May 22, 2024 19:44
rdimaio added a commit to rdimaio/rucio that referenced this pull request May 24, 2024
Ruff 0.4.5 changes the logic used to detect UP037,
mainly via this PR: astral-sh/ruff#11485.

I am seeing some possible false positive due to this, e.g.:

> Error: lib/rucio/core/authentication.py:571:27: UP037 Remove quotes from type annotation

where it asks to remove quotes from  a type
that's only imported in a type-checking block.

This is a very new Ruff version so it's best to check back at a later
point to see if this is a common issue for other repositories too.
bari12 pushed a commit to rucio/rucio that referenced this pull request May 24, 2024
Ruff 0.4.5 changes the logic used to detect UP037,
mainly via this PR: astral-sh/ruff#11485.

I am seeing some possible false positive due to this, e.g.:

> Error: lib/rucio/core/authentication.py:571:27: UP037 Remove quotes from type annotation

where it asks to remove quotes from  a type
that's only imported in a type-checking block.

This is a very new Ruff version so it's best to check back at a later
point to see if this is a common issue for other repositories too.
bari12 pushed a commit to rucio/rucio that referenced this pull request May 24, 2024
Ruff 0.4.5 changes the logic used to detect UP037,
mainly via this PR: astral-sh/ruff#11485.

I am seeing some possible false positive due to this, e.g.:

> Error: lib/rucio/core/authentication.py:571:27: UP037 Remove quotes from type annotation

where it asks to remove quotes from  a type
that's only imported in a type-checking block.

This is a very new Ruff version so it's best to check back at a later
point to see if this is a common issue for other repositories too.
labkode pushed a commit to labkode/rucio that referenced this pull request Jun 26, 2024
Ruff 0.4.5 changes the logic used to detect UP037,
mainly via this PR: astral-sh/ruff#11485.

I am seeing some possible false positive due to this, e.g.:

> Error: lib/rucio/core/authentication.py:571:27: UP037 Remove quotes from type annotation

where it asks to remove quotes from  a type
that's only imported in a type-checking block.

This is a very new Ruff version so it's best to check back at a later
point to see if this is a common issue for other repositories too.
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
1 participant