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 positives for quoted-type-alias (TC008) #16688

Open
ntBre opened this issue Mar 12, 2025 · 0 comments
Open

False positives for quoted-type-alias (TC008) #16688

ntBre opened this issue Mar 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ntBre
Copy link
Contributor

ntBre commented Mar 12, 2025

Recursive type definition from ibis:

if sys.version_info >= (3, 10):
    from types import UnionType
    from typing import TypeAlias

    # Keep this alias in sync with unittest.case._ClassInfo
    _ClassInfo: TypeAlias = type | UnionType | tuple["_ClassInfo", ...]
else:
    from typing_extensions import TypeAlias

    UnionType = object()
    _ClassInfo: TypeAlias = Union[type, tuple["_ClassInfo", ...]]  # TC008

Conditional import from zulip:

if settings.ZILENCER_ENABLED:
    from zilencer.models import RemoteInstallationCount, RemoteRealmCount, RemoteZulipServer

...

TableType: TypeAlias = (
        type["RemoteInstallationCount"]  # TC008
        | type[InstallationCount]
        | type["RemoteRealmCount"]
        | type[RealmCount]

These all look like false positives except the latchbio cases.

The Zulip cases require an import that is conditional on some settings type other than TYPE_CHECKING, so I think unconditionally unquoting those could be a problem.

And the ibis case is a recursive type alias, which I think must be quoted? Possibly the rule doesn't descend into the Union because it handles the ... | ... version fine.

Originally posted by @ntBre in #16639 (comment)

See this ecosystem check for what "these" refers to and this comment for additional context and possible solutions.

@ntBre ntBre added the bug Something isn't working label Mar 12, 2025
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

No branches or pull requests

1 participant