-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-141388: Fully support non-function callables as annotate functions #141449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dr-carlos
wants to merge
33
commits into
python:main
Choose a base branch
from
dr-carlos:non-function-annotate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+704
−19
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
0328ac1
Add `_get_annotate_attr()` to access attrs on non-func annotates, and…
dr-carlos d98ef64
Implement non-func callable annotate support for `call_annotate_funct…
dr-carlos b600f8c
Fix `__code__` access in `_build_closure` for non-func annotates
dr-carlos a9a7f88
Add `_direct_call_annotate()` and support callable classes
dr-carlos 4703e8d
Support `functools.partial` objects as annotate functions
dr-carlos 6e31007
Support placeholders in `functools.partial` annotate functions
dr-carlos f752c48
Add tests for `call_annotate_function()` with classes, instances, and…
dr-carlos 9e4faa4
Test `get_annotations()` on callable class instance
dr-carlos c4d8d9d
Support `functools.cache` callables in `call_annotate_function()`
dr-carlos a83ca8f
Improve quality of test for cached annotate function
dr-carlos e6bc7a0
Don't create an unused new cache wrapper for cached annotate functions
dr-carlos 2e4b927
Test `functools` wrapped as annotate function
dr-carlos 4b955a8
Support `functools.partialmethod` annotate functions
dr-carlos f5ea8a0
Test `functools.singledispatch`/`functools.singledispatchmethod` anno…
dr-carlos a43a873
Support methods as annotate functions
dr-carlos a3b68ee
Test classmethods and staticmethods as annotate functions
dr-carlos ea60223
Update and simplify classmethod/staticmethod annotate function tests
dr-carlos c16083b
Add standard method annotate function test
dr-carlos ba1927c
Support and test generics as annotate callables
dr-carlos b96532f
Add secondary test for staticmethod as annotate function
dr-carlos e70b489
Test `typing._BaseGenericAlias` callables as annotate functions
dr-carlos 8df3d24
Support recursive unwrapping of annotate functions
dr-carlos 61b76a5
Support recursive unwrapping and calling of methods as annotate funct…
dr-carlos ac888cc
Support (recursively unwrap/call) any type of callable as an annotati…
dr-carlos 6a48bbe
Add test to actually instantiate class for callable class as an annot…
dr-carlos 1d35db0
Test that `GenericAlias` objects which cannot have `__orig_class__` s…
dr-carlos c2cccff
Improve comments and cleanup new tests
dr-carlos 2ca8f95
Improve test for annotation function as method of non-function callable
dr-carlos 33c9d13
Support fake globals in Python generic classes' __init__ methods
dr-carlos d2dc8a3
Improve comments for annotate callables in `annotationlib`
dr-carlos 4acb56b
Add NEWS entry
dr-carlos b749c49
Support arbitrary callables as __init__ methods for class annotate fu…
dr-carlos a76d794
Improve error message when `__code__` attribute is not found on annot…
dr-carlos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I don't think we should add all this complexity to support increasingly exotic kinds of callables. Things that quack like a function (in terms of attributes) should work and we should give reasonable errors if something goes wrong, but I don't think we should go out of our way to support various other stdlib callables and try to figure out what the user meant.