Refactor/alias kwargs#775
Merged
Merged
Conversation
…args The internals package __init__ had grown into a grab-bag mixing keyword/alias resolution with rc, location, and lazy-import helpers. Move the cohesive keyword-argument cluster (_not_none, _alias_maps, the _pop_* poppers, and the signature helpers) into a dedicated internals/kwargs.py, and re-export them from the package so every existing 'from ..internals import _not_none' keeps working unchanged. Add a new _alias_kwargs decorator that folds synonym keywords into their canonical names with the same precedence and conflict warning as _not_none, replacing the repetitive 'x = _not_none(x=x, y=y)' boilerplate at the top of aliased functions.
Replace the six-line block of _not_none alias resolutions at the top of Figure.__init__ with a single @_alias_kwargs table and drop the redundant alias parameters (ref, aspect, axwidth, axheight, width, height) from the signature; they are now folded into their canonical names before the body runs. Behavior is unchanged, including the conflict warning and the refnum default of 1. This is the first real adopter of the new decorator and the pattern for retiring the scattered _not_none alias boilerplate elsewhere.
Adversarial review found that dropping the six _not_none lines let an explicit Figure(refnum=None) survive as None instead of collapsing to 1 the way _not_none(refnum=refnum, ref=ref, default=1) did, which loses the reference axes and changes the figure size. Restore the canonical None default and coerce it with a single _not_none call, and cover the case in the tests. Also reword the decorator's conflict warning so it no longer implies the canonical keyword was passed when two synonyms collide, and document that it handles keyword aliases only.
The reusable style-parameter snippets (line, patch, pcolor/contour collections,
text) opened each numpydoc field with a pile of alias names like
'lw, linewidth, linewidths :', which every plotting method inherited and which
made the parameter tables hard to scan. Lead each field with the canonical name
and move the common documented synonyms into a short trailing 'Aliases:' note,
built through a small _aliases_note helper. This also fixes a drifted typo in the
contour snippet ('a, alpha, alpha' -> 'a, alpha, alphas'). Behavior is unchanged;
all synonyms are still accepted at runtime via _pop_props.
The geo format docstring documented gridline-locator aliases as separate 'lonlines, latlines : optional / Aliases for lonlocator, latlocator' blocks sitting next to the canonical entries, doubling the number of parameter entries a reader scans. Fold each alias set into a trailing 'Aliases:' note on its canonical entry (lonlocator, lonlocator_kw, lonminorlocator, lonminorlocator_kw), matching the shared style-snippet presentation. Documentation only; the alias keywords are still accepted.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cvanelteren
marked this pull request as ready for review
July 18, 2026 09:54
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.
Replacement of #774 which was dirty
This PR replaces the long inputs for aliases into a decorator to clean up some boilerplate code that exists.
Note that the functionality does not change, it just organizes it in a nicer manner to for both coders and users (I think).