MagicStack / MagicStack/asyncpg
Value yielded by PoolAcquireContext is mistyped by IDEs
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
- asyncpg version: 0.21.0
- PostgreSQL version: 12.5
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: No - Python version: 3.9.1
- Platform: Windows 10
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: N/A
- Can the issue be reproduced under both asyncio and
uvloop?: N/A
Using PyCharm Professional 2020.2 by JetBrains, the typing of conn is interpreted incorrectly in the following expression:
pool = await asyncpg.create_pool('postgres://...')
async with pool.acquire() as conn:
await conn.execute(...)
Expected: asyncpg.Connection
Observed: typing.Any
Suggested remedy: Explicitly type PoolAcquireContext.connection as typing.Optional[Connection] and/or explicitly type PoolAcquireContext.pool as Pool.
Caveat: The suggestions above will break compatibility with Python 3.4, which reached end of life in March 2019.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 PoolAcquireContext 类型定义开始,在 PyCharm 中复现 pool.acquire() 示例,以检查 conn 推断出的类型。将 connection 和 pool 的注解与所声明的预期类型 asyncpg.Connection 进行比较,同时检查 Python 3.4 兼容性注意事项。当 IDE 能够正确推断 conn 且不丢失受支持的兼容性时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100