8000 Exclude irrelevant members in `narrow_declared_type` from union overlapping with enum by sterliakov · Pull Request #18897 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Exclude irrelevant members in narrow_declared_type from union overlapping with enum #18897

New issue

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

Merged
merged 6 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review comments
  • Loading branch information
sterliakov committed Apr 9, 2025
commit c8bd14800b255d13ef9fca2399cd3448fd7ef699
1 change: 1 addition & 0 deletions test-data/unit/check-typeguard.test
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ def process_model(model: Union[MODEL_A, MODEL_B]) -> int:

def handle(model: Model) -> int:
if is_model_a(model) or is_model_b(model):
reveal_type(model) # N: Revealed type is "__main__.Model"
return process_model(model)
return 0
[builtins fixtures/tuple.pyi]
1 change: 1 addition & 0 deletions test-data/unit/check-typeis.test
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ class Model(str, Enum):

def is_model_a(model: str) -> TypeIs[Literal[Model.A, "foo"]]:
return True

def handle(model: Model) -> None:
if is_model_a(model):
reveal_type(model) # N: Revealed type is "Literal[__main__.Model.A]"
Expand Down
0