-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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 can’t recognize part of built-in callable objects #123473
Labels
type-bug
An unexpected behavior, bug, or error
Comments
>>> import builtins
... import inspect
...
... for attribute in dir(builtins):
... obj = getattr(builtins, attribute)
... if callable(obj):
... try:
... signature = inspect.signature(obj)
... print(f'builtins.{attribute}{signature}')
... except ValueError as exception:
... print(f'{exception!r}')
...
ValueError("no signature found for builtin type <class 'ArithmeticError'>")
ValueError("no signature found for builtin type <class 'AssertionError'>")
ValueError("no signature found for builtin type <class 'AttributeError'>")
ValueError("no signature found for builtin type <class 'BaseException'>")
ValueError("no signature found for builtin type <class 'BaseExceptionGroup'>")
ValueError("no signature found for builtin type <class 'BlockingIOError'>")
ValueError("no signature found for builtin type <class 'BrokenPipeError'>")
ValueError("no signature found for builtin type <class 'BufferError'>")
ValueError("no signature found for builtin type <class 'BytesWarning'>")
ValueError("no signature found for builtin type <class 'ChildProcessError'>")
ValueError("no signature found for builtin type <class 'ConnectionAbortedError'>")
ValueError("no signature found for builtin type <class 'ConnectionError'>")
ValueError("no signature found for builtin type <class 'ConnectionRefusedError'>")
ValueError("no signature found for builtin type <class 'ConnectionResetError'>")
ValueError("no signature found for builtin type <class 'DeprecationWarning'>")
ValueError("no signature found for builtin type <class 'EOFError'>")
ValueError("no signature found for builtin type <class 'EncodingWarning'>")
ValueError("no signature found for builtin type <class 'OSError'>")
ValueError("no signature found for builtin type <class 'Exception'>")
ValueError("no signature found for builtin type <class 'ExceptionGroup'>")
ValueError("no signature found for builtin type <class 'FileExistsError'>")
ValueError("no signature found for builtin type <class 'FileNotFoundError'>")
ValueError("no signature found for builtin type <class 'FloatingPointError'>")
ValueError("no signature found for builtin type <class 'FutureWarning'>")
ValueError("no signature found for builtin type <class 'GeneratorExit'>")
ValueError("no signature found for builtin type <class 'OSError'>")
ValueError("no signature found for builtin type <class 'ImportError'>")
ValueError("no signature found for builtin type <class 'ImportWarning'>")
ValueError("no signature found for builtin type <class 'IndentationError'>")
ValueError("no signature found for builtin type <class 'IndexError'>")
ValueError("no signature found for builtin type <class 'InterruptedError'>")
ValueError("no signature found for builtin type <class 'IsADirectoryError'>")
ValueError("no signature found for builtin type <class 'KeyError'>")
ValueError("no signature found for builtin type <class 'KeyboardInterrupt'>")
ValueError("no signature found for builtin type <class 'LookupError'>")
ValueError("no signature found for builtin type <class 'MemoryError'>")
ValueError("no signature found for builtin type <class 'ModuleNotFoundError'>")
ValueError("no signature found for builtin type <class 'NameError'>")
ValueError("no signature found for builtin type <class 'NotADirectoryError'>")
ValueError("no signature found for builtin type <class 'NotImplementedError'>")
ValueError("no signature found for builtin type <class 'OSError'>")
ValueError("no signature found for builtin type <class 'OverflowError'>")
ValueError("no signature found for builtin type <class 'PendingDeprecationWarning'>")
ValueError("no signature found for builtin type <class 'PermissionError'>")
ValueError("no signature found for builtin type <class 'ProcessLookupError'>")
ValueError("no signature found for builtin type <class 'PythonFinalizationError'>")
ValueError("no signature found for builtin type <class 'RecursionError'>")
ValueError("no signature found for builtin type <class 'ReferenceError'>")
ValueError("no signature found for builtin type <class 'ResourceWarning'>")
ValueError("no signature found for builtin type <class 'RuntimeError'>")
ValueError("no signature found for builtin type <class 'RuntimeWarning'>")
ValueError("no signature found for builtin type <class 'StopAsyncIteration'>")
ValueError("no signature found for builtin type <class 'StopIteration'>")
ValueError("no signature found for builtin type <class 'SyntaxError'>")
ValueError("no signature found for builtin type <class 'SyntaxWarning'>")
ValueError("no signature found for builtin type <class 'SystemError'>")
ValueError("no signature found for builtin type <class 'SystemExit'>")
ValueError("no signature found for builtin type <class 'TabError'>")
ValueError("no signature found for builtin type <class 'TimeoutError'>")
ValueError("no signature found for builtin type <class 'TypeError'>")
ValueError("no signature found for builtin type <class 'UnboundLocalError'>")
ValueError("no signature found for builtin type <class 'UnicodeDecodeError'>")
ValueError("no signature found for builtin type <class 'UnicodeEncodeError'>")
ValueError("no signature found for builtin type <class 'UnicodeError'>")
ValueError("no signature found for builtin type <class 'UnicodeTranslateError'>")
ValueError("no signature found for builtin type <class 'UnicodeWarning'>")
ValueError("no signature found for builtin type <class 'UserWarning'>")
ValueError("no signature found for builtin type <class 'ValueError'>")
ValueError("no signature found for builtin type <class 'Warning'>")
ValueError("no signature found for builtin type <class 'ZeroDivisionError'>")
ValueError("no signature found for builtin type <class '_IncompleteInputError'>")
ValueError('no signature found for builtin <built-in function __build_class__>')
builtins.__import__(name, globals=None, locals=None, fromlist=(), level=0)
builtins.__loader__()
builtins.abs(x, /)
builtins.aiter(async_iterable, /)
builtins.all(iterable, /)
ValueError('<built-in function anext> builtin has invalid signature')
builtins.any(iterable, /)
builtins.ascii(obj, /)
builtins.bin(number, /)
builtins.bool(object=False, /)
builtins.breakpoint(*args, **kws)
ValueError("no signature found for builtin type <class 'bytearray'>")
ValueError("no signature found for builtin type <class 'bytes'>")
builtins.callable(obj, /)
builtins.chr(i, /)
builtins.classmethod(function, /)
builtins.compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1, *, _feature_version=-1)
builtins.complex(real=0, imag=0)
builtins.copyright()
builtins.credits()
builtins.delattr(obj, name, /)
ValueError("no signature found for builtin type <class 'dict'>")
ValueError('no signature found for builtin <built-in function dir>')
builtins.divmod(x, y, /)
builtins.enumerate(iterable, start=0)
builtins.eval(source, /, globals=None, locals=None)
builtins.exec(source, /, globals=None, locals=None, *, closure=None)
builtins.exit(code=None)
builtins.filter(function, iterable, /)
builtins.float(x=0, /)
builtins.format(value, format_spec='', /)
builtins.frozenset(iterable=(), /)
ValueError('no signature found for builtin <built-in function getattr>')
builtins.globals()
builtins.hasattr(obj, name, /)
builtins.hash(obj, /)
builtins.help(*args, **kwds)
builtins.hex(number, /)
builtins.id(obj, /)
builtins.input(prompt: 'object' = '') -> 'str'
ValueError("no signature found for builtin type <class 'int'>")
builtins.isinstance(obj, class_or_tuple, /)
builtins.issubclass(cls, class_or_tuple, /)
ValueError('no signature found for builtin <built-in function iter>')
builtins.len(obj, /)
builtins.license()
builtins.list(iterable=(), /)
builtins.locals()
builtins.map(function, iterable, /, *iterables)
ValueError('no signature found for builtin <built-in function max>')
builtins.memoryview(object)
ValueError('no signature found for builtin <built-in function min>')
ValueError('no signature found for builtin <built-in function next>')
builtins.object()
builtins.oct(number, /)
builtins.open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
builtins.ord(c, /)
builtins.pow(base, exp, mod=None)
builtins.print(*args, sep=' ', end='\n', file=None, flush=False)
builtins.property(fget=None, fset=None, fdel=None, doc=None)
builtins.quit(code=None)
ValueError("no signature found for builtin type <class 'range'>")
builtins.repr(obj, /)
builtins.reversed(sequence, /)
builtins.round(number, ndigits=None)
builtins.set(iterable=(), /)
builtins.setattr(obj, name, value, /)
ValueError("no signature found for builtin type <class 'slice'>")
builtins.sorted(iterable, /, *, key=None, reverse=False)
builtins.staticmethod(function, /)
ValueError("no signature found for builtin type <class 'str'>")
builtins.sum(iterable, /, start=0)
ValueError("no signature found for builtin type <class 'super'>")
builtins.tuple(iterable=(), /)
ValueError("no signature found for builtin <class 'type'>")
ValueError('no signature found for builtin <built-in function vars>')
builtins.zip(*iterables, strict=False) This is a WIP. Because some signatures require multi-signatures supports, see #73536 I am going to close this, because there are other open issues to track this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Bug description:
I’m not sure if this is a bug, but I’m wondering why
inspect.signature
can’t provide the signature of all built-in callable objects. If they are callable, they should have a signature, so I think it might be considered a bug.A list of all the exceptions raised when trying to get the signature of all callable objects directly from the
builtins
module.Code to reproduce the behaviour:
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: