-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
shutil.copyfileobj stopped working in 1.2.0 #15031
Comments
Yeah, I ran into this too. Seems triggered by change in typeshed: https://github.com/python/mypy/pull/14902/files#diff-363460977156fcfda748f21565484fe1d5862edf2823e9784cbf34d1e52ff2f2 |
Should I open an issue over there, then? |
I think this is actually a mypy bug, though one that was exposed through the typeshed change. It would help to try to create a reproducer that doesn't rely on the stdlib (basically, copy-paste in the definitions of |
Here's a minimal-ish repro that doesn't rely on typeshed's stdlib stubs: from typing import AnyStr, Generic, Protocol, TypeVar, overload
T_co = TypeVar("T_co", covariant=True)
T_contra = TypeVar("T_contra", contravariant=True)
class SupportsRead(Generic[T_co]):
def read(self) -> T_co: ...
class SupportsWrite(Protocol[T_contra]):
def write(self, s: T_contra) -> object: ...
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr]) -> None: ...
class WriteToMe(Generic[AnyStr]):
@overload
def write(self: WriteToMe[str], s: str) -> int: ...
@overload
def write(self: WriteToMe[bytes], s: bytes) -> int: ...
class WriteToMeOrReadFromMe(WriteToMe[AnyStr], SupportsRead[AnyStr]): ...
copyfileobj(WriteToMeOrReadFromMe[bytes](), WriteToMe[bytes]()) https://mypy-play.net/?mypy=latest&python=3.11&gist=7443887f86538e58f87bc9b6f1957ce5 It does indeed end up looking very similar to #14943. |
This requires an explicit `cast` of `shutil.copyfileobj` to work-around a typeshed/Mypy issue. Bumps [mypy](https://github.com/python/mypy) from 1.1.1 to 1.4.1. - [Commits](python/mypy@v1.1.1...v1.4.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... See: python/mypy#15031 See: https://github.com/python/mypy/pull/14902/files#diff-363460977156fcfda748f21565484fe1d5862edf2823e9784cbf34d1e52ff2f2 See: python/mypy#14975 Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Nicolas Trangez <ikke@nicolast.be>
This requires an explicit `cast` of `shutil.copyfileobj` to work-around a typeshed/Mypy issue. Bumps [mypy](https://github.com/python/mypy) from 1.1.1 to 1.4.1. - [Commits](python/mypy@v1.1.1...v1.4.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... See: python/mypy#15031 See: https://github.com/python/mypy/pull/14902/files#diff-363460977156fcfda748f21565484fe1d5862edf2823e9784cbf34d1e52ff2f2 See: python/mypy#14975 Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Nicolas Trangez <ikke@nicolast.be>
This requires an explicit `cast` of `shutil.copyfileobj` to work-around a typeshed/Mypy issue. Bumps [mypy](https://github.com/python/mypy) from 1.1.1 to 1.4.1. - [Commits](python/mypy@v1.1.1...v1.4.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... See: python/mypy#15031 See: https://github.com/python/mypy/pull/14902/files#diff-363460977156fcfda748f21565484fe1d5862edf2823e9784cbf34d1e52ff2f2 See: python/mypy#14975 Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Nicolas Trangez <ikke@nicolast.be>
Thanks! Type ignore removed in pypa/cibuildwheel#2054. |
Bug Report
MyPy 1.2.0 doesn't like
shutil.copyfileobj
anymore, with "can't infer type argument 1".Hit in pypa/cibuildwheel#1468.
To Reproduce
Expected Behavior
https://mypy-play.net/?mypy=1.1.1&python=3.11&gist=7f9fbe8e5df5f52e5c639e30671eb208
Actual Behavior
https://mypy-play.net/?mypy=latest&python=3.11&gist=dbc914004646a0c0ad90926c501d1daa
Your Environment
mypy.ini
(and other config files): (Seen in playground with nothing)The text was updated successfully, but these errors were encountered: