Class types in containers: help option, known subclasses and set parsing; harden import path policy - #960
Merged
Conversation
…ions are postponed
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #960 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 8762 8784 +22
=========================================
+ Hits 8762 8784 +22 ☔ 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?
Follow-up to #959 with a few unrelated fixes on top. Four commits, each self-contained.
Class types nested in containers
--*.helpis now available for class types nested in atuple,set,frozensetor mapping (e.g.dict[str, SomeBaseClass]), not only in alist.get_class_typeshelper shared by help, extra help and shell completion.--*.helpoption gave wrong choices when the class type was nested in a container or optional, e.g.builtins.NoneTypeforOptional[list[SomeBaseClass]].set/frozensetof a class type failed to parse because subclass specs are not hashable. Such values are now kept as a list while parsing and become a set oninstantiate.Import path policy
jsonargparseitself is denied by default and rejected inimport_path_allowlist, since a value naming it could callset_parsing_settingsand change the policy that is checking it.ActionParserno longer goes throughimport_objectfor its own class.builtins.breakpoint/help/getattr/setattr/delattr/vars/globals/exit/quit,cProfile,profile,doctest,unittest,_frozen_importlib*,pkg_resources,ensurepip,_sitebuiltins,resource,faulthandler,codecs.open,winreg,xml,antigravity.omegaconfparser modes bypass the denylist through OmegaConf resolvers (e.g.${oc.env:...}) and should be avoided for untrusted configs.Postponed annotations
Literalwith arguments that are attributes of the class in whose body the method is defined now resolves. The class attribute values are only added as aliases for names inside aLiteralsubscript, so they can't shadow a global in a type position.Misc
pragma: no coverin_stubs_resolver.py, covered by a test.without-future-annotationstox env now uses{envtmpdir}instead of a fixed/tmppath, andsed -i.bakso it works on macOS.Before submitting