-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
Sorry for the rambling title – I couldn't think of a good description of this:
import shutil
from typing import TYPE_CHECKING, AnyStr
from io import BufferedWriter
if TYPE_CHECKING:
from _typeshed import SupportsRead, SupportsWrite
def f(s: SupportsRead[AnyStr], t: SupportsWrite[AnyStr]) -> None: # with TypeVar
shutil.copyfileobj(s, t)
def g(s: SupportsRead[bytes], t: SupportsWrite[bytes]) -> None: # with concrete type
shutil.copyfileobj(s, t)
def h(src: SupportsRead[bytes], tgt: BufferedWriter) -> None:
f(src, tgt) # E: Argument of type "BufferedWriter" cannot be assigned to parameter "t" of type "SupportsWrite[AnyStr@f]" in function "f"
g(src, tgt)Expected behavior
If I can pass tgt succesfully to g, then I don't see why it would fail with f. Clearly, BufferedWriter is compatible with SupportsWrite[bytes].
VS Code extension or command-line
command-line
Additional context
This happened after updating to the most recent version. I believe there were typeshed changes around this code.
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working