class Animal: @classmethod def create(cls) -> Self: # Returns instance of the current class return cls()

Python 3.11 fixes this. When an error occurs, the interpreter now points an arrow ( ^ ) at the specific expression that failed, not just the line number. python 3.11