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

Rule idea: check for complex function type annotations #7845

Closed
tjkuson opened this issue Oct 7, 2023 · 2 comments
Closed

Rule idea: check for complex function type annotations #7845

tjkuson opened this issue Oct 7, 2023 · 2 comments
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule

Comments

@tjkuson
Copy link
Contributor

tjkuson commented Oct 7, 2023

It would be nice to have a lint rule that checks for convoluted type annotations, similar to rules that check for complicated functions.

The recommendation would be to move the type information to a type alias or to create a new data type (such as a NamedTuple) to refactor type information.

I don't have a specific idea about how the rule should measure type complexity (it could involve measuring nesting, unions, or just the number of parameters); I am more interested in checking if there would be an appetite for any such rule in Ruff at the moment!

@tjkuson tjkuson changed the title Rule idea: check for convoluted function type annotations Rule idea: check for complex function type annotations Oct 7, 2023
@charliermarsh charliermarsh added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Oct 8, 2023
@strmwalker
Copy link

There is a rule in wemake-python-styleguide https://wemake-python-styleguide.readthedocs.io/en/latest/pages/usage/violations/complexity.html#wemake_python_styleguide.violations.complexity.TooComplexAnnotationViolation
You can take a look at #3845

@AlexWaygood
Copy link
Member

Thanks for the feature request! I'm going to close this in favour of #2323, as it seems like basically the same idea to me (happy to reopen if I'm mistaken!)

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

4 participants