Skip to content
Advertisement

Tag: python-descriptors

Python – TypeHint for Descriptor

I would like to have a base class for all my descriptors which is of type descriptor: Is it correct to use the GetSetDescriptorType? Now when I declare A pycharm inspection complains: get() does not match signature. I have looked up the signature which is: Is it an error in inspection or is my declaration wrong? Answer No, using GetSetDescriptor

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

Advertisement