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

Support the banned-import-alias #3892

Closed
stancld opened this issue Apr 5, 2023 · 1 comment · Fixed by #3926
Closed

Support the banned-import-alias #3892

stancld opened this issue Apr 5, 2023 · 1 comment · Fixed by #3926
Labels
rule Implementing or modifying a lint rule

Comments

@stancld
Copy link
Contributor

stancld commented Apr 5, 2023

🚀 Feature request

Currently, ruff supports enforcing importing packages/modules under aliases. It would be, however, nice to have a feature to forbid some aliases which might be considered non-standard at some companies.

For example, with a hypothetical configuration

[tool.ruff.flake8-import-conventions.forbidden-aliases]
"tensorflow.keras.backend" = "K"

the following import

>>> import tensorflow.keras.backend as K

should raise an error.

Thanks a lot for all your hard work. Ruff is an amazing tool ❤️

@stancld stancld changed the title Support the other variant of unconventional-import-alias Support the other variant of unconventional-import-alias Apr 5, 2023
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Apr 5, 2023
@charliermarsh
Copy link
Member

Ooh, I almost replied saying we support this via aliases, but you're talking about the inverse: ban certain aliases. That makes sense to me! (And thank you for the kind words :))

@stancld stancld changed the title Support the other variant of unconventional-import-alias Support the banned-import-alias Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants