Skip to content

Returning an instance of sibiling inner class #1920

Answered by erictraut
ivoras asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ivoras
Comment options

Answer selected by ivoras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants