Repository navigation
Look up params, attrs and raises by name - #197
Merged
Merged
Conversation
Add Docstring.params_by_name, attrs_by_name and raises_by_type next to the lists they mirror. Each is a read-only Mapping built from meta on every access, so it can't go stale, and a name given twice maps to its first item, as returns takes the first return. Raises with no type are left out. Closes #89.
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.
Add read-only lookups by name next to the lists they mirror, as asked in #89:
Docstring.params_by_name,attrs_by_nameandraises_by_type.Mapping[str, ...]property: atypes.MappingProxyTypeover a dict built frommetaon every access. Nothing is cached, so a lookup always matchesmeta, and both the type checker and the runtime reject writes to it.returnstakes the first return. The lists keep every item. For raises this means two conditions that raiseValueErrorgive the first one;raisesstill has both. Raises with no type are left out.raises_by_typecovers whatraiseslists, so warns are in it too.methods_by_name: a method's name is its signature as written, such asrun(x, y=1), so a lookup by it would rarely be useful.test_kinds.pycover each style, a repeated name, raises with and without a type, and that a lookup is read-only and follows changes tometa.Closes #89.