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

runtime-cast-value (TC006) shouldn't apply to stubs #15176

Closed
Avasam opened this issue Dec 29, 2024 · 1 comment · Fixed by #15179
Closed

runtime-cast-value (TC006) shouldn't apply to stubs #15176

Avasam opened this issue Dec 29, 2024 · 1 comment · Fixed by #15179

Comments

@Avasam
Copy link
Contributor

Avasam commented Dec 29, 2024

Found this whilst applying various Ruff groups on typeshed.

According to the updated typing spec for typing enums (see Mypy: Change to Enum Membership Semantics and https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members, this is the recommended way to type an enum in stubs where the type is known but the value isn't:

class Key(enum.Enum):
    alt = cast(KeyCode, ...)
    alt_l = cast(KeyCode, ...)
    alt_r = cast(KeyCode, ...)
    alt_gr = cast(KeyCode, ...)
    # ...

This will trigger runtime-cast-value (TC006)

Related: #15132

Ruff: 0.8.4
Command: ruff check --preview --select=TC006 --isolated

@Daverball
Copy link
Contributor

Daverball commented Dec 29, 2024

My bad, some of the other new flake8-type-checking rules I added might also currently be active in stub files. None of them should really be active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants