New submission from Filippo Vicentini <filippovicent...@gmail.com>:

Attempting to inspect the signature of a method marked as @staticmethod during 
class construction fails.
This happens in 3.8, 3.9.

A MWE is given here:
```python
from typing import signature

def decorator(fun):
        print(signature(fun))
        return fun

class Test2:
        @decorator
        @staticmethod
        def test(arg):
                return arg
```
which fails with error
```python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in Test
  File "<stdin>", line 2, in decorator
  File 
"/Users/filippovicentini/.pyenv/versions/3.9.7/lib/python3.9/inspect.py", line 
3111, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File 
"/Users/filippovicentini/.pyenv/versions/3.9.7/lib/python3.9/inspect.py", line 
2860, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File 
"/Users/filippovicentini/.pyenv/versions/3.9.7/lib/python3.9/inspect.py", line 
2259, in _signature_from_callable
    raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: <staticmethod object at 0x108865250> is not a callable object
```

----------
components: Library (Lib)
messages: 407715
nosy: PhilipVinc
priority: normal
severity: normal
status: open
title: inspect.signature fails on a @staticmethod
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to