[New-bugs-announce] [issue42503] Cannot declare method or static function parameter or return type as self of the class

parsa mpsh report at bugs.python.org
Sun Nov 29 07:58:55 EST 2020


New submission from parsa mpsh <parsampsh at gmail.com>:

python raises error `Undefined class X` when you declaring parameter type or return type of method as the self of class:

class MyClass:
    def mymethod(self, a: MyClass): # parameter type is class self
        pass

# or

class MyClass:
    def mymethod(self) -> MyClass: # return type is class self
        pass
# or both of them

error `Undefined class ...` will be raised.

----------
messages: 382061
nosy: parsampsh
priority: normal
severity: normal
status: open
title: Cannot declare method or static function parameter or return type as self of the class
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42503>
_______________________________________


More information about the New-bugs-announce mailing list