Skip to content

shutil.copyfileobj stopped working in 1.2.0 #15031

Closed
@henryiii

Description

@henryiii

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

import shutil
import typing

stdin = typing.cast(typing.IO[bytes], None)
with open("random_file.txt", "rb") as from_file:
    shutil.copyfileobj(from_file, stdin)

Expected Behavior

$ pipx run mypy==1.1.1 --strict tmp.py
Success: no issues found in 1 source file

https://mypy-play.net/?mypy=1.1.1&python=3.11&gist=7f9fbe8e5df5f52e5c639e30671eb208

Actual Behavior

$ pipx run mypy==1.2.0 --strict tmp.py
tmp.py:6: error: Cannot infer type argument 1 of "copyfileobj"  [misc]
Found 1 error in 1 file (checked 1 source file)

https://mypy-play.net/?mypy=latest&python=3.11&gist=dbc914004646a0c0ad90926c501d1daa

Your Environment

  • Mypy version used: 1.1.1 & 1.2.0
  • Mypy command-line flags: (Seen in playground with nothing)
  • Mypy configuration options from mypy.ini (and other config files): (Seen in playground with nothing)
  • Python version used: 3.11 and others.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions