Type "reactive[None]" cannot be assigned to type #1977
Answered
by
davep
davetapley
asked this question in
Q&A
-
The docs here don't explicitly show it, but I presume this is should be valid: name: reactive[str | None] = reactive(None) But in VSCode / Pylance I get:
I initially tried: name: reactive[str | None] = reactive() But that causes:
|
Beta Was this translation helpful? Give feedback.
Answered by
davep
Mar 8, 2023
Replies: 1 comment 4 replies
-
As best as I've been able to tell, this is an issue with pyright/pylance. I see it too when using pyright in Emacs. I'm finding I have to give pyright a helping hand like this: name: reactive[str | None] = reactive[str | None](None) or, to be compatible with some older supported Pythons: name: reactive[str | None] = reactive[Optional[str]](None) (assuming |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
davep
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As best as I've been able to tell, this is an issue with pyright/pylance. I see it too when using pyright in Emacs. I'm finding I have to give pyright a helping hand like this:
or, to be compatible with some older supported Pythons:
(assuming
Optional
is imported fromtyping
).