We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isinstance
False positive unbound variables, see example below:
class A: ... class B: ... # works fine def test_1(obj: A | B) -> None: if isinstance(obj, A): new_name = "test" elif isinstance(obj, B): new_name = "test" a = new_name # breaks def get_obj() -> A | B: ... def test_2() -> None: obj = get_obj() if isinstance(obj, A): new_name = "test" elif isinstance(obj, B): new_name = "test" # "new_name" is possibly unbound a = new_name
The text was updated successfully, but these errors were encountered:
Pyright is working as designed here, so this isn't a bug.
See this documentation for limitations on "implied else" narrowing.
Sorry, something went wrong.
Okay, I guess a function return type is too implicit for this :( As a workaround obj: A | B = get_obj() seems to work fine.
obj: A | B = get_obj()
No branches or pull requests
False positive unbound variables, see example below:
The text was updated successfully, but these errors were encountered: