Skip to content
Advertisement

Tag: callable

mypy error: Callable has no attribute “__get__”

I have something like the following: …for which Mypy will return this error: What is the canonical way to specify the type for func, so that Mypy understands it is a descriptor (and thus always has a __get__)? Update: it’s a bit humorous that “descriptor” has no hits when searching the Mypy help. Answer This appears to work fine on

Python – What does it mean for a Class to be callable?

I am trying to understand what ‘callables’ are in Python and what it means for a class to be callable. I was playing with the following code: This gives the following result: Furthermore, Gives: Does this mean that class A has a __call__ method? and why is it of type class? is A.__call__() being called each time I instantiate with

dynamically adding callable to class as instance “method”

I implemented a metaclass that tears down the class attributes for classes created with it and builds methods from the data from those arguments, then attaches those dynamically created methods directly to the class object (the class in question allows for easy definition of web form objects for use in a web testing framework). It has been working just fine,

Advertisement