-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
inspect.signature returns incorrect result on a @staticmethod and a @classmethod #101293
Comments
I don't think that |
It is from pyparsing, Here is the test suite. I want to do this and got a bug in inspect module. Is there a way to find out which descriptor wrapped a method? |
….Signature.from_callable() Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
This is an interesting issue, and it is larger that what #102564 covers.
#115530 is more general, and supports more different cases. It does not support all cases. There is an explicit exclusion for builtin methods and descriptors in the current code, and I keep it for now. It can be significantly weakened (allowing to support more weird cases), but this can also break some Cython generated classes, so we should be careful. More general approach would ignore signatures like |
…ture.from_callable() (GH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
….Signature.from_callable() (pythonGH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors. (cherry picked from commit 59167c9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
….Signature.from_callable() (pythonGH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors. (cherry picked from commit 59167c9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…t.Signature.from_callable() (GH-115530) (GH-116197) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors. (cherry picked from commit 59167c9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…t.Signature.from_callable() (GH-115530) (GH-116198) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors. (cherry picked from commit 59167c9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
….Signature.from_callable() (pythonGH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
….Signature.from_callable() (pythonGH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
….Signature.from_callable() (pythonGH-115530) Support callables with the __call__() method and types with __new__() and __init__() methods set to class methods, static methods, bound methods, partial functions, and other types of methods and descriptors. Add tests for numerous types of callables and descriptors.
Bug report
Your environment
CPython versions tested on:
Possible fix
The problem is that we are calling
_signature_from_callable
twice withskip_bound_arg=True
.A simple solution is to call
_get_signature_of
withskip_bound_arg=False
oncpython/Lib/inspect.py
Line 2610 in f02fa64
That fix the
test_2
but not thetest_1
. I need to think about how to do better. I will be glad to your suggestions.Р.S I would like to submit a pull request.
Linked PRs
__call__
decorated withstaticmethod
andclassmethod
decorators. #102564The text was updated successfully, but these errors were encountered: