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

Extending specific rule configurations #10836

Closed
seamuswn opened this issue Apr 8, 2024 · 1 comment
Closed

Extending specific rule configurations #10836

seamuswn opened this issue Apr 8, 2024 · 1 comment

Comments

@seamuswn
Copy link

seamuswn commented Apr 8, 2024

When extending another file, I want to be able to extend the 'banned-api' configuration. The specific use case here is to ban some imports specifically for a subset of my test files (unit tests shouldn't access code intended for integration tests).

The current behaviour is for banned-api to be overwritten completely when set in my file, requiring managing my project level bans in any file that wants to extend the list of banned APIs.

I think that ideally any configurations like [tool.ruff.lint.flake8-tidy-imports.banned-api] should also support the extend = '../pyproject.toml syntax (so users can choose between extending the existing configuration option or replacing it - and avoiding breaking changes here).

Other configuration options that might benefit from similar semantics (that I don't use but just from 👀 settings page in docs):

  1. [tool.ruff.lint.flake8-import-conventions.aliases]
  2. [tool.ruff.lint.flake8-import-conventions.banned-aliases]
  3. tool.ruff.lint.flake8-import-conventions.extend-aliases]

It would also be useful to have similar semantics somehow for list based configurations, but I'm unsure how that could be supported cleanly.

Keywords:
extend TID251 flake8-tidy-imports banned-api

Note: this would also be solved by #1507 if implemented (which suggests making banned-api a core feature of ruff with a dedicated select / ignore configuration.

@MichaReiser
Copy link
Member

Thanks for the detailed write-up. I think this is a duplicate of #9872 and there's a PR that fixes this but we need to wait for the next minor.

Please comment if this is about something else and I incorrectly closed your issue.

@MichaReiser MichaReiser closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2024
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

No branches or pull requests

2 participants