|
This is what I'm currently trying to do: class Tools:
class Response:
pass
class Widget:
def f(self) -> Response:
passPyLance 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? |
Answered by
erictraut
Feb 4, 2025
Replies: 1 comment 1 reply
|
If you run this code, the Python interpreter raises a |
1 reply
Answer selected by
ivoras
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you run this code, the Python interpreter raises a
NameErrorexception: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.