TypeDict "dict style" positional arguments
未关闭
还没有人认领这个 Issue。
topic: documentation
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 302
- 平均合并
- 23 小时
- 30 天内合并 PR
- 8
描述
Hi.
I'm just curious why passing arguments to TypeDict is strictly constrained. I tried some variants including positional arguments style and failed. It's not reflected in docs or function signature (ctrl + p in Pycharm)
https://docs.python.org/3/library/typing.html#typing.TypedDict
In [1]: from typing import TypedDict
In [2]:
...: ProfileText = TypedDict(name='ProfileText', fields={'name': str, 'non variable key': str}, total=False) # Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-7d3b7c9254f3> in <module>
----> 1 ProfileText = TypedDict(name='ProfileText', fields={'name': str, 'non variable key': str}, total=False) # Error
TypeError: _typeddict_new() missing 1 required positional argument: 'typename'
In [3]:
...: ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, total=False) # Error
In [4]:
...: ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, False) # Error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-b3b55e028c98> in <module>
----> 1 ProfileText = TypedDict('ProfileText', {'name': str, 'non variable key': str}, False) # Error
TypeError: _typeddict_new() takes from 2 to 3 positional arguments but 4 were given
In [5]:
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 提到了 TypedDict 入口点和 Python typing 文档;首先将所示的关键字调用形式和位置调用形式与该文档进行比较。确定应支持哪种调用约定,然后将完成定义为:针对所接受形式,行为、签名信息、文档和测试保持一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100