Closed
Description
Bug Report
When matching overloads, a type: ignore
is not passed into the underlying type check.
To Reproduce
Have this code:
from typing import Awaitable, Generic, TypeVar, overload
_R_co = TypeVar("_R_co", covariant=True)
_R = TypeVar("_R")
class Job(Generic[_R_co]):
...
@overload
def run_job(job: Job[Awaitable[_R]], a: int) -> _R | None: ...
@overload
def run_job(job: Job[Awaitable[_R] | _R], a: int) -> _R | None: ...
def run_job(job: Job[Awaitable[_R] | _R], a: int) -> _R | None: ...
job: Job[Awaitable[None] | None]
run_job(
job,
"", # type: ignore[arg-type]
)
# "" is a stand-in for an invalid type.
# Passing an int would make the error go away.
Expected Behavior
Type checks fine.
Actual Behavior
repro.py:18: error: No overload variant of "run_job" matches argument types "Job[Optional[Awaitable[None]]]", "str"
repro.py:18: note: Possible overload variants:
repro.py:18: note: def [_R] run_job(job: Job[Awaitable[_R]], a: int) -> Optional[_R]
repro.py:18: note: def [_R] run_job(job: Job[Union[Awaitable[_R], _R]], a: int) -> Optional[_R]
Your Environment
- Mypy version used: 81994f1 (based off master)
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.10.2
- Operating system and version: Windows 11