In which situation sys.modules["__main__"].__file__
is None
?
#3332
Unanswered
Diogo-Rossi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I saw a pylance warning in a code, complaining about the types of
sys.modules["__main__"].__file__
.By inspecting its type, I could see that the type is
str | None
.I know that this attribute doesn't exist in some situations (Python REPL), but in which situation it is
None
?The line raising the warning is the following. Is this related to type
None
or is there some another problem?Message:
Type "str | None" is incompatible with constrained type variable "AnyStr"
Beta Was this translation helpful? Give feedback.
All reactions