:rtype: specifies that this is type of returned object
Therefore, when I create object obj
in following snippet I receive warning from IDE, that cls is not callable
, since IDE expects, that cls
is object
of type SomeAbstractClass
, and I want SomeAbstractClass
itself
IDE is right, since this is default behaviour. But how can I specify, that I am returning class, not instance of class?
Specifying type
instead of SomeAbstractClass
helps a bit, but not a solution, since no further introspection available.
def class_selector(data):
"""
:rtype: SomeAbstractClass
:return: Return some class based on given parameters
"""
return get_from.get(data.name)
cls = class_selector(data)
obj = cls(data.more_data)
Meanwhile i solve this by adding """:type: SomeAbstractClass"""
after object creating, but this does not cancel the warning and it's dirty solution.
Btw, talking about python 2.x