Skip to content
Advertisement

Tag: polymorphism

Polymorphism and Type Hints in Python

Consider the following case: Let’s say I’m calling get_base_instance in a context where I kow it will return a Sub instance – maybe based on what args I’m passing. Now I want to pass the returned instance to do_something_with_sub: The problem is that my IDE complains about passing a Base instance to a method that only accepts a Sub instance.

Advertisement