Files
RustPython/extra_tests/snippets/builtin_callable.py
Rex Ledesma 4e2e0b41c6 chore: add ruff format --check (#5774)
* chore: add `ruff format --check`

* fix tests
2025-05-12 14:20:01 +09:00

49 lines
576 B
Python

assert not callable(1)
def f():
pass
assert callable(f)
assert callable(len)
assert callable(lambda: 1)
assert callable(int)
class C:
def __init__(self):
# must be defined on class
self.__call__ = lambda self: 1
def f(self):
pass
assert callable(C)
assert not callable(C())
assert callable(C().f)
class C:
def __call__(self):
pass
assert callable(C())
class C1(C):
pass
assert callable(C1())
class C:
__call__ = 1
# CPython returns true here, but fails when actually calling it
assert callable(C())