New GitHub issue #101293 from heckad:<br>
<hr>
<pre>
<!--
If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
the right place to seek help. Consider the following options instead:
- reading the Python tutorial: https://docs.python.org/3/tutorial/
- posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
- emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
- searching our issue tracker (https://github.com/python/cpython/issues) to see if
your problem has already been reported
-->
# Bug report
```
import inspect
def test_1():
class FooStaticmethod:
@staticmethod
def __call__(cls, s, l, t):
return t
instance = FooStaticmethod()
instance(1, 2, 3, 4) # Success call with 4 args
assert list(inspect.signature(instance).parameters.keys()) == ['cls', 's', 'l', 't']
def test_2():
class FooClassmethod:
@classmethod
def __call__(cls, s, l, t):
return t
instance = FooClassmethod()
instance(1, 2, 3) # Success call with 4 args
assert list(inspect.signature(instance).parameters.keys()) == ['s', 'l', 't']
```
# Your environment
CPython versions tested on:
- Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
- Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
# Possible fix
The problem is that we are calling `_signature_from_callable` twice with `skip_bound_arg=True`.
A simple solution is to call `_get_signature_of` with `skip_bound_arg=False` on
https://github.com/python/cpython/blob/f02fa64bf2d03ef7a28650c164e17a5fb5d8543d/Lib/inspect.py#L2610
That fix the `test_2` but not the `test_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.
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/101293">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>