相关疑难解决方法(0)

Python: how to override type hint on an instance attribute in a subclass?

Before you dive in, here is my question: how can I use type hints in a subclass to specify a different type on an instance attribute?

If you are unclear on what that means, read below, where I have drawn up an example to clarify things.


Full Explanation

I have an abstract class Foo, and a subclass of Foo called SubclassOfFoo.

Foo has an abstract method get_something that returns an object of type Something.

Something has a …

python typing subclass type-hinting pycharm

9
推荐指数
2
解决办法
3301
查看次数

标签 统计

pycharm ×1

python ×1

subclass ×1

type-hinting ×1

typing ×1