New Untyped type, fail_untyped='all' and debug logs for adjusted signature parameters - #965
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #965 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 28 28
Lines 9209 9235 +26
=========================================
+ Hits 9209 9235 +26 ☔ 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?
fail_untyped=Trueonly fails for required parameters without a type annotation. One that has a default is silently added asUnion[<type of the default>, Any], indistinguishable in the help from a parameter genuinely annotated asAny, and there was no way to require that everything the parser exposes is typed.New
Untypedtype. Parameters without a type annotation are now added asUntypedinstead ofAny, so the help says what is actually the case:It is a subclass of
UnvalidatedType, thus accepts any value without validation asAnydid, and union ordering,dump,--print_configand the JSON schema treat it identically.Uniform type. With
fail_untyped=Falsea parameter with a default used to get plainAny, i.e. the stricter setting was the one inferring from the default. Both now giveUnion[<type of the default>, Untyped], leaving one rule: an untyped parameter getsUntypedwhen required andUnion[<type of the default>, Untyped]when it has a default, andfail_untypedonly decides whether to raise instead.fail_untyped="all". Raises for every untyped parameter, not only the required ones, and propagates into subclass types.TrueandFalsekeep their meaning and are not deprecated."all"is only viable for code you own, since one untyped parameter of a dependency makes its signature impossible to add, so the default is unchanged.Debug logs for five previously silent cases where the type or the requiredness differs from the signature: no type annotation, a parameter skipped because its name starts with
_, aNonedefault widening the type toOptional, aNotRequiredparameter without a default, and a link target. Nothing is logged for the two behaviors that v5 removes.Also:
UnvalidatedType.__eq__and__hash__now include the class, and the "Unvalidated types" section and signature notes were shortened while documenting the above.Before submitting