python / python/typeshed

Invalid overloads in `asyncio.(base_)events`

Đang mở
#9,652 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@JelleZijlstra đang làm issue này rồi.

Từ ngày 1/2/2023.

topic: asyncio
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ả

Stubdefaulter would like us to apply this diff to our asyncio stubs. Stubdefaulter is correct about what the defaults are for these functions at runtime, but mypy correctly points out that applying this diff as-is would be invalid: a parameter annotated with str cannot have a None default, etc. etc.

Plainly, these overloads are incorrect in some way. Unfortunately, I'm not sure what the correct fix is. I'd appreciate it if somebody who knows their asyncio better than I do would be able to take a look :)

(This is a followup issue to #9608, which is completed other than this remaining issue.)

The affected functions are:

  • asyncio.base_events.create_connection
  • asyncio.base_events.create_server
  • asyncio.events.create_connection
  • asyncio.events.create_server
diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi
index 3b8f28671..7e0601863 100644
--- a/stdlib/asyncio/base_events.pyi
+++ b/stdlib/asyncio/base_events.pyi
@@ -156,8 +156,8 @@ class BaseEventLoop(AbstractEventLoop):
         async def create_connection(
             self,
             protocol_factory: Callable[[], _ProtocolT],
-            host: str = ...,
-            port: int = ...,
+            host: str = None,
+            port: int = None,
             *,
             ssl: _SSLContext = None,
             family: int = 0,
@@ -284,7 +284,7 @@ class BaseEventLoop(AbstractEventLoop):
             self,
             protocol_factory: _ProtocolFactory,
             host: str | Sequence[str] | None = None,
-            port: int = ...,
+            port: int = None,
             *,
             family: int = ...,
             flags: int = ...,
@@ -305,7 +305,7 @@ class BaseEventLoop(AbstractEventLoop):
             *,
             family: int = ...,
             flags: int = ...,
-            sock: socket = ...,
+            sock: socket = None,
             backlog: int = 100,
             ssl: _SSLContext = None,
             reuse_address: bool | None = None,
diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi
index b2292801e..cff0775d6 100644
--- a/stdlib/asyncio/events.pyi
+++ b/stdlib/asyncio/events.pyi
@@ -250,8 +250,8 @@ class AbstractEventLoop:
         async def create_connection(
             self,
             protocol_factory: Callable[[], _ProtocolT],
-            host: str = ...,
-            port: int = ...,
+            host: str = None,
+            port: int = None,
             *,
             ssl: _SSLContext = None,
             family: int = 0,
@@ -388,7 +388,7 @@ class AbstractEventLoop:
             self,
             protocol_factory: _ProtocolFactory,
             host: str | Sequence[str] | None = None,
-            port: int = ...,
+            port: int = None,
             *,
             family: int = ...,
             flags: int = ...,
@@ -410,7 +410,7 @@ class AbstractEventLoop:
             *,
             family: int = ...,
             flags: int = ...,
-            sock: socket = ...,
+            sock: socket = None,
             backlog: int = 100,
             ssl: _SSLContext = None,
             reuse_address: bool | None = None,

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.