-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
mypy 0.930: regression: no longer keeping contextmanager generic return value #11852
Labels
bug
mypy got something wrong
Comments
Thanks, I will have a look! 👍 |
@sobolevn I think it was a misunderstanding about send type in that PR -- there's no meaning of send types for let me know if you want me to turn this into a patch: diff --git a/mypy/plugins/default.py b/mypy/plugins/default.py
index 67587090e..c57c5f9a1 100644
--- a/mypy/plugins/default.py
+++ b/mypy/plugins/default.py
@@ -15,7 +15,6 @@ from mypy.types import (
from mypy.subtypes import is_subtype
from mypy.typeops import make_simplified_union
from mypy.checkexpr import is_literal_type_like
-from mypy.checker import detach_callable
class DefaultPlugin(Plugin):
@@ -192,12 +191,12 @@ def contextmanager_callback(ctx: FunctionContext) -> Type:
and isinstance(default_return, CallableType)):
# The stub signature doesn't preserve information about arguments so
# add them back here.
- return detach_callable(default_return.copy_modified(
+ return default_return.copy_modified(
arg_types=arg_type.arg_types,
arg_kinds=arg_type.arg_kinds,
arg_names=arg_type.arg_names,
variables=arg_type.variables,
- is_ellipsis_args=arg_type.is_ellipsis_args))
+ is_ellipsis_args=arg_type.is_ellipsis_args)
return ctx.default_return_type
diff --git a/test-data/unit/check-default-plugin.test b/test-data/unit/check-default-plugin.test
index fc9f132ab..6a89aa266 100644
--- a/test-data/unit/check-default-plugin.test
+++ b/test-data/unit/check-default-plugin.test
@@ -29,10 +29,9 @@ from contextlib import contextmanager
from typing import TypeVar, Generator
T = TypeVar('T')
-S = TypeVar('S')
@contextmanager
-def yield_id(item: T) -> Generator[T, S, None]:
+def yield_id(item: T) -> Generator[T, None, None]:
yield item
reveal_type(yield_id) # N: Revealed type is "def [T] (item: T`-1) -> contextlib.GeneratorContextManager[T`-1]"
@@ -70,10 +69,9 @@ from contextlib import asynccontextmanager
from typing import TypeVar, AsyncGenerator
T = TypeVar('T')
-S = TypeVar('S')
@asynccontextmanager
-async def yield_id(item: T) -> AsyncGenerator[T, S]:
+async def yield_id(item: T) -> AsyncGenerator[T, None]:
yield item
reveal_type(yield_id) # N: Revealed type is "def [T] (item: T`-1) -> typing.AsyncContextManager[T`-1]" |
asottile
added a commit
to pre-commit/pre-commit
that referenced
this issue
Dec 27, 2021
asottile
added a commit
to asottile/git-code-debt
that referenced
this issue
Dec 28, 2021
@asottile please, go ahead. Let's try this solution. |
JukkaL
pushed a commit
that referenced
this issue
Jan 5, 2022
JukkaL
pushed a commit
that referenced
this issue
Jan 5, 2022
asottile
added a commit
to pre-commit/pre-commit
that referenced
this issue
Jan 10, 2022
This reverts commit 83675fe.
asottile
added a commit
to asottile/git-code-debt
that referenced
this issue
Jan 10, 2022
This reverts commit e17580a.
tushar-deepsource
pushed a commit
to DeepSourceCorp/mypy
that referenced
this issue
Jan 20, 2022
clrpackages
pushed a commit
to clearlinux-pkgs/pypi-pre_commit
that referenced
this issue
Jan 20, 2022
…version 2.17.0 Anthony Sottile (11): add setuptools to the zipapp. resolves #2122 minor py2 cleanup for sys.stderr.buffer replace echo image with focal run dead, remove dead code work around python/mypy#11852 forbid overriding `entry` for meta hooks always use #!/bin/sh on windows Revert "work around python/mypy#11852" add git version to error output get lua version from luarocks itself v2.17.0 Jamie Alessio (1): Update rbenv / ruby-build versions Lorenz Walthert (3): better r path detection unset renv project no docs Matt Layman (1): Add naive and untested version of Lua language support. Ralf Schmitt (1): Use 'go install' instead of 'go get' Tony Rintala (2): fix: Add missing warning for regular expression with [\\/] fix: regex lists to regex tuples Uwe L. Korn (1): Add mamba support to `language: conda` pre-commit-ci[bot] (4): [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate [pre-commit.ci] pre-commit autoupdate
saravankrish
pushed a commit
to saravankrish/pre-commit
that referenced
this issue
Jul 7, 2023
saravankrish
pushed a commit
to saravankrish/pre-commit
that referenced
this issue
Jul 7, 2023
This reverts commit 83675fe.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
I bisected this, the regression was introduced in #11352 CC @BarnabyShearer @sobolevn
here's a minimal case split out from
pre-commit
:To Reproduce
mypy t.py
Expected Behavior
I expect it to pass (as it did with 0.920)
Actual Behavior
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: