-
-
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 codetopic-protocolstopic-type-variables
Description
This code generates a false positive, but type checked cleanly on mypy 1.11:
from typing import IO
from shutil import copyfileobj
f: IO[str]
copyfileobj(f, f) # Cannot infer type argument 1 of "copyfileobj"
I believe the reason is that the definition of IO.write
changed in typeshed, and this triggered a mypy bug. Here's how IO.write
is currently defined:
class IO(Iterator[AnyStr]):
...
@abstractmethod
@overload
def write(self: IO[bytes], s: ReadableBuffer, /) -> int: ...
@abstractmethod
@overload
def write(self, s: AnyStr, /) -> int: ...
vfazio
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codetopic-protocolstopic-type-variables