-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
Found this while writing tests for mypy, even though the first overload is technically redundant.
Code or Screenshots
from typing import Any
from typing_extensions import TypeVar, overload, assert_type
T1 = TypeVar("T1", default=str)
class A: ...
class B: ...
@overload
def func_1(x: A) -> A: ...
@overload
def func_1(x: B | T1) -> T1: ...
def func_1(x: Any) -> Any: ...
assert_type(func_1(A()), A)
assert_type(func_1(B()), str) # errortest.py
test.py:15:13 - error: "assert_type" mismatch: expected "str" but received "Unknown" (reportAssertTypeFailure)
In comparison, this works just fine
def func_2(x: B | T1) -> T1: ...
assert_type(func_2(A()), A)
assert_type(func_2(B()), str)VS Code extension or command-line
pyright 1.1.349
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working