You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is correct. If you try to run this in the Python interpreter, it will generate a runtime exception because the UMLClass isn't defined at that point of execution. You can work around this by enclosing the type annotation in quotes. Type checkers will then treat it as a "forward-declared reference". This is the recommended approach documented in PEP 484.
If you are using Python 3.7+, you can use the future statement from __future__ import annotations to enable this postponed annotation evaluation that we see in the initial comment. Pylance seems to stop complaining.
If you are using Python 3.11+, you can use the typing.Self type.
The type of a variable is not defined inside a method of its own class?
![image](https://user-images.githubusercontent.com/10444460/146599977-046c80f8-4363-4228-9543-66c80eed417b.png)
The text was updated successfully, but these errors were encountered: