-
This is what I'm currently trying to do: class Tools:
class Response:
pass
class Widget:
def f(self) -> Response:
pass PyLance is reporting this as a "Response is not defined" error. It seems to me that it should be supported because at least because of the top-down order of evaluation, but I could be missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you run this code, the Python interpreter raises a |
Beta Was this translation helpful? Give feedback.
If you run this code, the Python interpreter raises a
NameError
exception:name 'Response' is not defined
. Pyright (the type checker upon which pylance is built) is telling you about this runtime exception. This is due to the (somewhat confusing) scoping rules in Python for class bodies. Symbols defined in a class body are visible within the class body itself but are not visible to inner scopes.