Invalid overloads in `asyncio.(base_)events`
未关闭
@JelleZijlstra 已经在做这个了。
开始于 2023年2月1日。
topic: asyncio
- 主要语言
- Python
- 星标
- 5.1k
- 派生
- 2.1k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 82
描述
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_connectionasyncio.base_events.create_serverasyncio.events.create_connectionasyncio.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,
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。