Python upcast failure

It appears that Static Python doesn’t support upcasting. I am curious if I’m doing something incorrectly, or if there is there a technique or workaround.

Demo project:

The demo code:

class Animal:
def init(self, name: str):
self.name: str = name
def printname(self):
print(self.name)

class Dog(Animal):
def init(self, name):
super().init(name)

a: Animal = None
a = Dog(“terrier”) # ← types not compatible: Animal and Dog
a.printname()

1 Like