Skip to content
Advertisement

Tag: callable-object

Python how to type hint a Callable with __wrapped__

When passing around functions, I normally type hint them with typing.Callable. The docs for collections.abc.Callable state that it has four dunder methods: class collections.abc.Callable ABCs for classes that provide respectively the methods __contains__(), __hash__(), __len__(), and __call__(). At one point, I want to check if there is a __wrapped__ attribute on a function. This works fine at runtime via a

Advertisement