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

Implement rule for unnecessary import alias #3437

Closed
stinodego opened this issue Mar 10, 2023 · 4 comments
Closed

Implement rule for unnecessary import alias #3437

stinodego opened this issue Mar 10, 2023 · 4 comments
Labels
question Asking for support or clarification

Comments

@stinodego
Copy link
Contributor

stinodego commented Mar 10, 2023

This is a feature request to implement the following lint from the flake8-tidy-imports package:
https://github.com/adamchainz/flake8-tidy-imports#i250-unnecessary-import-alias

Apparently, it is also an isort rule:
https://pycqa.github.io/isort/docs/configuration/options.html#remove-redundant-aliases

@stinodego stinodego changed the title Implement TID250: Unnecessary import alias Implement rule for unnecessary import alias Mar 10, 2023
@charliermarsh
Copy link
Member

I think we support this as PLC0414, Pylint's "useless-import-alias" rule.

@charliermarsh
Copy link
Member

In combination with PLR0402, Pylint's "consider-using-from-import" rule.

@charliermarsh charliermarsh added the question Asking for support or clarification label Mar 11, 2023
@stinodego
Copy link
Contributor Author

Oh great, that was indeed what I was looking for! Thanks for the help.

Still, I think this raises another question, which is: what to do about rules that are implemented by multiple sources? I'd argue that by enabling the TID lints, I should expect these rules to be enabled.

In any case, I have what I need for now. I'll close this issue - the point I raised above could get its own separate issue if you feel it's merited.

@charliermarsh
Copy link
Member

Attaching this to #2186, where we're tracking these kinds of known aliases. I agree that enabling TID should give you this rule, and internally we actually do support rule aliasing, we just haven't figured out all of the details -- there are some tricky cases which make the "right" behavior unclear.

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

No branches or pull requests

2 participants