subprocess stdout read1
Open
Beginner friendly
Nobody has claimed this yet.
stubs: false positive
topic: io
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100