class Element:
def __call__(self, *args, **kwargs):
print('Hello')
return self
class Button(Element):
pass
class TextBox(Element):
pass
def some_func(element: Element) -> Element:
return element()
some_func(Button)
some_func(TextBox)
Pycharm mentions "Expected type 'Element', got 'Type[Button]' instead ". Is there any proper way to get type of the return as parent of all it's children?
x: Elementmeans thatxis an instance of theElementclass.Use
type[Element]when you mean to pass a subclass ofElement.