-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-high
Description
This generates a false positive in g
:
from typing import Generator, Callable, Iterator, TypeVar, ContextManager, Any
from typing_extensions import ParamSpec
from nonexistent import deco # type: ignore
_T = TypeVar("_T")
_P = ParamSpec("_P")
_T_co = TypeVar("_T_co", covariant=True)
_F = TypeVar("_F", bound=Callable[..., Any])
class _GeneratorContextManager(ContextManager[_T_co]):
def __call__(self, func: _F) -> _F: ...
def contextmanager(
func: Callable[_P, Iterator[_T]]) -> Callable[_P, _GeneratorContextManager[_T]]: ...
@contextmanager
@deco
def f() -> Generator[str, None, None]:
pass
def g() -> Generator[str, None, None]:
with f() as x: # <<<--------- Need type annotation for "x"
yield x
This is a regression so it's high priority. It was introduced by me in #11594.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-high