Way to specify KW_ONLY location in the constructor like in dataclass.KW_ONLY
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
Use the linked Python dataclasses.KW_ONLY documentation and the two examples as the behavioral reference. Inspect attrs' constructor generation and existing keyword-only and inheritance tests; done means attrs can express the requested marker behavior, preserves the shown constructor ordering, and has coverage for both examples.
由索引模型根据 Issue 内容生成。
描述
dataclass in python 3.10 and above got KW_ONLY sentinel value
it allows you to mark where the constructor will start the KWARGS in the class
https://docs.python.org/3/library/dataclasses.html#dataclasses.KW_ONLY
i did not found a way to do this in attrs package
@dataclass()
class Foo():
x:str=field(default="a")
_:KW_ONLY
y:bool
the function signature of the init will be
(x: str = "a", *, y: bool) -> None
the dataclass one will re order the items order in the constructor and handle inheritance properly(if needed)
https://docs.python.org/3/library/dataclasses.html#re-ordering-of-keyword-only-parameters-in-init
from dataclasses import dataclass,KW_ONLY,field
@dataclass
class Base:
x: float = 15.0
_: KW_ONLY
y: int = 0
w: int = 1
@dataclass
class D(Base):
z: int = 10
_: KW_ONLY
t: int = field(kw_only=False, default=0)
function signature:
(x: float = 15, z: int = 10, t: int = 0, *, y: int = 0, w: int = 1) -> None
- 主要语言
- Python
- 星标
- 5.9k
- 派生
- 501
- 平均合并
- 4 天 18 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-attrs/attrs 的其他 Issue
-
Docs: `attrs.filters` is missing stated examples可能已有人在做 @feiiiiii5 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
python-attrs/attrs#1627 ·
维护者通常 2 天内回复
-
slots declared on attrs-decorated class are ignored/lost可能已有人在做 @anshurajbisoyi98-ctrl 于 14 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
python-attrs/attrs#1637 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
python-attrs/attrs#1620 ·
维护者通常 2 天内回复
-
Incorrect annotation for forward reference in generated constructor可能已有人在做 @MohammedAnasNathani 于 79 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
python-attrs/attrs#1596 · 2 条评论 · 2 个 reaction ·
维护者通常 2 天内回复
-
Decorated functions do not work with inheritance可能已有人在做 @sb123sb123 于 26 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
python-attrs/attrs#1549 · 3 条评论 ·
维护者通常 2 天内回复
查看 python-attrs/attrs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#140958 ·
维护者通常 1 天内回复
-
bisect
难度 2/5 1-3 小时 新手友好度 72/100
dtcxzyw/llvm-bisect-service#548 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
sallowayma-git/IELTS-practice#248 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 65/100
anthropics/claude-plugins-official#6763 · 10 条评论 · 10 个 reaction ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复