Replies: 1 comment
-
|
Could you provide a complete code sample that demonstrates the problem you're seeing? The code sample above is incomplete in that it has syntax errors and references variables that are not defined. If I modify it to eliminate these problems, it type checks without problems, so there's likely some other issue in your code that's at fault here. def func(var: list[str] | None, x: str):
if var is None:
return False
if x not in var:
return TrueI'm also switching this from a bug report to a discussion topic since this is unlikely to be a bug in pyright but rather a question about how type checking works. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Hi,
I am doing:
And I keep getting:
the first if is already ensuring that the variable is not None so it can only be a list and the error should not happen.
Beta Was this translation helpful? Give feedback.
All reactions