Type hint asyncio.Process streams (stdin, stdout, stderr) when created with values other than default None
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 5.1k
- Fork
- 2.1k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 82
Mô tả
Is it possible to update asyncio stub files so that asyncio.Process.{stdin,stdout,stderr} are resolved as non-None by mypy?
Example:
from asyncio import create_subprocess_exec
from asyncio.subprocess import PIPE
async def main() -> None:
proc = await create_subprocess_exec('/usr/bin/ls', stdout=PIPE)
async for line in proc.stdout:
print(line)
Typing error reported by mypy (desired behaviour is no error):
error: Item "None" of "StreamReader | None" has no attribute "__aiter__" (not async iterable) [union-attr]
Current asyncio.Process declaration in typeshed/stdlib/asyncio/subprocess.pyi:
class Process:
stdin: streams.StreamWriter | None
stdout: streams.StreamReader | None
stderr: streams.StreamReader | None
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với khai báo Process trong typeshed/stdlib/asyncio/subprocess.pyi và lần theo các khai báo subprocess của asyncio được create_subprocess_exec sử dụng. Tái hiện lỗi mypy từ ví dụ của issue, sau đó xác minh rằng việc truyền PIPE khiến các thuộc tính stream liên quan trở thành không tùy chọn mà không thay đổi hành vi None mặc định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- developer-experience
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100