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

PYI026/type-alias-without-annotation false positives with None in Enum #11117

Closed
Avasam opened this issue Apr 23, 2024 · 2 comments · Fixed by #11128
Closed

PYI026/type-alias-without-annotation false positives with None in Enum #11117

Avasam opened this issue Apr 23, 2024 · 2 comments · Fixed by #11128
Assignees
Labels
bug Something isn't working rule Implementing or modifying a lint rule

Comments

@Avasam
Copy link

Avasam commented Apr 23, 2024

class VariablePolicy(Enum):
    EXPAND_DISTRIBUTED_VARIABLES = "expand_distributed_variables"
    NONE = None
    SAVE_VARIABLE_DEVICES = "save_variable_devices"

(taken from https://github.com/python/typeshed/blob/ed7f35a2bc53610d5166cbccbb965fc97cfdbac4/stubs/tensorflow/tensorflow/saved_model/experimental.pyi#L34-L37 )

Running ruff check --fix --select=PYI026 results in:

stubs\tensorflow\tensorflow\saved_model\experimental.pyi:36:5: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NONE: TypeAlias = None`
Found 1 error.
[*] 1 fixable with the `--fix` option.

Version: ruff 0.4.1

@AlexWaygood
Copy link
Member

Yup. I think we just need to port over the fix I made the other week in PyCQA/flake8-pyi@1279f1e. Should be pretty simple.

How's your Rust — fancy making a PR? :-) If not, I can do it

@AlexWaygood AlexWaygood added bug Something isn't working rule Implementing or modifying a lint rule labels Apr 23, 2024
@Avasam
Copy link
Author

Avasam commented Apr 23, 2024

How's your Rust

Its in my news cycle, other than that I never touched Rust, but I'm considering it next time I wanna (and have time to) learn a new language.

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

Successfully merging a pull request may close this issue.

2 participants