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
Feature
example.py
from __future__ import annotations import typing as t class Node: parent: Node | None = None N = t.TypeVar("N", bound=Node) def find_ancestor(node: Node, node_type: t.Type[N]) -> N | None: ancestor = node.parent while ancestor and not isinstance(ancestor, node_type): ancestor = ancestor.parent return ancestor
mypy 1.0.1 errors with:
example.py:13: error: Incompatible return value type (got "Optional[Node]", expected "Optional[N]") [return-value]
Would be great to narrow the type to N here and avoid the spurious error.
N
Pitch
Type narrowing in a while loop would improve inference. pyright already does this.
The text was updated successfully, but these errors were encountered:
Would this be a good issue to explore for a beginner? If so, can this issue be assigned to me?
Sorry, something went wrong.
No branches or pull requests
Feature
example.py
mypy 1.0.1 errors with:
Would be great to narrow the type to
N
here and avoid the spurious error.Pitch
Type narrowing in a while loop would improve inference. pyright already does this.
The text was updated successfully, but these errors were encountered: