Fix help types, dump skip_default, kwargs pop and shtab redraw - #954
Merged
Conversation
…nstead of a regex
…c is given for an argument whose default is None
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #954 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 8390 8444 +54
=========================================
+ Hits 8390 8444 +54 ☔ View full report in Codecov by Harness. |
|
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.



What does this PR do?
Four unrelated bug fixes, each in its own commit.
Mangled types in the help
type_to_strproduced the type string by running a regex overstr(typehint)tostrip module names. That regex also matched anything else with a dot, so floats,
dotted literal values and
...in aCallablecame out mangled, e.g.Literal[1.5]shown asLiteral[5].The string is now built by recreating the type hint with its subtypes already
converted to strings, so only the outermost level goes through the module name
stripping and literal values and
Annotatedmetadata are never touched. As partof this,
Nonein a PEP 604 union is now shown asnull, e.g.date | nullinstead of
date | None, matching what parsing actually accepts.--print_config=skip_defaultwith an optional subclassdumpwithskip_default=Truefailed withAttributeError: 'NoneType' object has no attribute 'get'when a subclass specwas given for an argument whose default is
None, e.g. anOptional[SomeClass]parameter. Now theclass_pathis kept in the dump andonly the
init_argsthat equal the defaults are removed.Parameters popped from
**kwargsand forwarded explicitlyA parameter taken with
kwargs.pop("x", None)orkwargs.get("x")disappearedfrom the resolved parameters when the value was afterwards forwarded as an
explicit keyword, e.g.
super().__init__(x=x, **kwargs). The explicit keywordwas treated as removing the parameter. A pop or get from
**kwargsnow marksthe parameter as accepted regardless of how it is forwarded.
shtab bash completion leaving the cursor on an empty line
When there are zero completions only the type guidance message is printed, so
readline does not redraw the prompt. The previous
kill -WINCHworkaround stoppedworking as of bash 5.3, since readline redraws only if the terminal size actually
changed. The completion now asks the terminal for a device status report and binds
the reply to
redraw-current-line, so readline redraws itself once the completionfunction returns.
Before submitting