[flake8-tidy-imports] Add extend-banned-api - #28644
Merged
Merged
Conversation
|
Member
|
|
MichaReiser
approved these changes
Sep 16, 2026
Comment on lines
+628
to
+629
|
|
||
| assert_cmd_snapshot!(fixture.check_command()); |
Member
There was a problem hiding this comment.
I think the snapshots are small enough that they can be inline snapshots (which is what we now mainly use for tests)
| fixture.write_file("child/nested/ruff.toml", "extend = \"../ruff.toml\"\n")?; | ||
| fixture.write_file( | ||
| "child/nested/test.py", | ||
| "import cgi\nimport pipes\nfrom typing import Any, TypedDict\n", |
Member
There was a problem hiding this comment.
My biggest annoyance with codex right now. Can you ask it to pretty please use rust multiline strings instead of squeezing every file on a single line (I believe write_file even calls dedent for you)
Comment on lines
+657
to
+661
| extend = "../ruff.toml" | ||
|
|
||
| [lint.flake8-tidy-imports.extend-banned-api] | ||
| "cgi".msg = "Use a supported library instead." | ||
| "typing.TypedDict".msg = "Use typing_extensions.TypedDict instead." |
Member
There was a problem hiding this comment.
I don't believe the indent here is necessary. Isn't CliTest calling dedent?
charliermarsh
enabled auto-merge (squash)
September 16, 2026 13:03
carljm
added a commit
that referenced
this pull request
Sep 16, 2026
…aliases * origin/main: Bump version to 0.16.8 (#28648) [ty] Bound aliased intersection expansion during inference (#28546) renovate: update uv hashes correctly with setup-uv (#28621) [ty] Compact reachable binding and declaration histories (#28349) [ty] Avoid storing constraint nodes twice (#28375) [ty] Compare bound-method receivers before signatures (#28384) [`flake8-type-checking`] Prefer lazy imports over `TYPE_CHECKING` on 3.15+ (`TC001`, `TC002`, `TC003`) (#28541) [ty] Watch script dependencies in CLI watch mode (#28125) [flake8-tidy-imports] Add `extend-banned-api` (#28644) [ty] Support `type[A & B]` (#27124) # Conflicts: # crates/ty_python_semantic/src/types/set_theoretic/builder.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
lint.flake8-tidy-imports.extend-banned-apiso we can add banned APIs without repeating an inheritedbanned-apitable. Entries inextend-banned-apioverride entries with the same key inbanned-api, including their diagnostic messages.For example, a child
ruff.tomlcan add a ban while retaining the bans from its base configuration:This follows the existing
extend-aliasesbehavior: the base and extension tables inherit independently, and we merge them after resolving configuration inheritance. A child can replace either table, or clear it with{}. The change includes option documentation, the generated JSON schema, and CLI coverage for standalone bans, inheritance, message overrides, and clearing either table.