subprocess stdout read1

Open Beginner friendly
#6,153 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
devtools

Research direction

Locate the subprocess.Popen stdout stub and inspect how its stream type is declared. Reproduce the issue with the provided Python snippet, then verify that mypy accepts read1() on process.stdout without losing the existing stdout typing.

Written by the indexing model from the issue text.

Description

stubs: false positive topic: io
import subprocess
process = subprocess.Popen("echo hello", shell=True, stdout=subprocess.PIPE)
assert process.stdout is not None
print(process.stdout.read1())

mypy error:

asd.py:4: error: "IO[bytes]" has no attribute "read1"; maybe "read"?
Found 1 error in 1 file (checked 1 source file)

But at runtime there is read1() method. It is useful because unlike read(), it will return the output as soon as it is available, instead of reading more until it gets n bytes or end of file.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 13h
Merged PRs (30d)
73

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/typeshed

All issues in python/typeshed

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.