[flake8-import-conventions] Document that extend-aliases can override default aliases - #27191
Merged
Merged
Conversation
ntBre
reviewed
Jul 27, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Thanks. As I noted on the issue, I'm not sure this is really an intended usage that we want to point users toward. I think I would make the minimal change necessary to acknowledge that this works, which would be something like:
/// A mapping from module to conventional import alias. These aliases will
/// be added to the [`aliases`](#lint_flake8-import-conventions_aliases) mapping
+/// and will override any existing `aliases` if the two settings overlap.Per review, keep the change minimal and just acknowledge that entries override an overlapping `aliases` entry, rather than presenting the self-alias trick as a recommended way to opt out of a default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Author
|
Makes sense — reduced to exactly your suggested wording in 47b31fb. Dropped the paragraph about using a self-alias to opt out of a default, and the The diff is now the one-liner you wrote, nothing else. |
ntBre
approved these changes
Jul 28, 2026
ntBre
enabled auto-merge (squash)
July 28, 2026 14:43
extend-aliases can override default aliasesflake8-import-conventions] Document that extend-aliases can override default aliases
ntBre
disabled auto-merge
July 28, 2026 14:44
ntBre
enabled auto-merge (squash)
July 28, 2026 14:44
|
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.
Closes #17097
Summary
The
extend-aliasesdocumentation only stated that entries "will be added to thealiasesmapping", which does not convey that an entry for a module that already has a default alias
replaces that default. As noted in the issue, this makes it possible to change or opt out
of a default alias without restating the whole
aliasesmapping.This is a documentation-only change; the behaviour already works this way because the
settings resolver applies
extend-aliaseson top ofaliasesviaHashMap::extend, somatching keys are overwritten.
Test Plan
Verified the documented behaviour against
ruff 0.12.4using this sample file:ICN001numpyshould be imported asnp`` on line 1numpy = "numpy"underextend-aliasesICN001numpyshould be imported asnumpy`` on line 2, i.e. the aliased import is now the violationnumpy = "nmp"underextend-aliasesnmp, so the defaultnpis fully replacedAlso ran:
cargo fmt --check- passes.cargo dev generate-all- regeneratedruff.schema.jsonso the new description isreflected there; confirmed the file is still valid JSON and contains the updated text.