8000 Narrow type variable bounds in binder by ilevkivskyi · Pull Request #19183 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Narrow type variable bounds in binder #19183

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 5 commits into from
Jun 3, 2025
Merged
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
Next Next commit
Merge remote-tracking branch 'upstream/master' into narrow-typevar-bo…
…unds
  • Loading branch information
ilevkivskyi committed Jun 3, 2025
commit 21a21530c06188715120c03eb1f1f188e900322b
18 changes: 18 additions & 0 deletions test-data/unit/check-typeguard.test
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,21 @@ def test(x: T) -> T:
reveal_type(x.x) # N: Revealed type is "Union[builtins.int, builtins.str]"
return x
[builtins fixtures/isinstance.pyi]

[case testOverloadedTypeGuardType]
from __future__ import annotations
from typing_extensions import TypeIs, Never, overload

class X: ...

@overload # E: An overloaded function outside a stub file must have an implementation
def is_xlike(obj: Never) -> TypeIs[X | type[X]]: ... # type: ignore
@overload
def is_xlike(obj: type) -> TypeIs[type[X]]: ...
@overload
def is_xlike(obj: object) -> TypeIs[X | type[X]]: ...

raw_target: object
if isinstance(raw_target, type) and is_xlike(raw_target):
reveal_type(raw_target) # N: Revealed type is "type[__main__.X]"
[builtins fixtures/tuple.pyi]
You are viewing a condensed version of this merge commit. You can view the full changes here.
0