Why `_types.finfo_object` and `_types.iinfo_object`, `_array_object._array` does not inherit `Protocol` ?

未关闭
#856 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
tooling

调研方向

阅读 src/array_api_stubs/_draft/_types.py 的第 60–79 行和 src/array_api_stubs/_draft/array_object.py 的第 19–20 行,然后将这些声明与 issue 中关于 Protocol 和 dataclass 的问题进行比较。该 issue 没有指定具体的更改或验收标准,因此完成此项工作需要 maintainer 就预期的类型设计作出明确决定。

由索引模型根据 Issue 内容生成。

描述

topic: Static Typing

https://github.com/data-apis/array-api/blob/6d205d72dde3db8fc8668ad6aef5d003cc8ef80f/src/array_api_stubs/_draft/_types.py#L60-L79

 class finfo_object(Protocol[dtype]): 
     """Dataclass returned by `finfo`.""" 
  
     bits: int 
     eps: float 
     max: float 
     min: float 
     smallest_normal: float 
     dtype: dtype 
  
  
 class iinfo_object(Protocol[dtype]): 
     """Dataclass returned by `iinfo`.""" 
  
     bits: int 
     max: int 
     min: int 
     dtype: dtype 

I wonder why they are defined as dataclass

https://github.com/data-apis/array-api/blob/6d205d72dde3db8fc8668ad6aef5d003cc8ef80f/src/array_api_stubs/_draft/array_object.py#L19-L20

array = TypeVar("array", bound="_array")

class _array(Protocol[Device, Dtype, PyCapsule, array])
	def __add__(self, other: Union[int, float, array], /) -> array:
主要语言
Python
星标
281
派生
52
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

data-apis/array-api 的其他 Issue

查看 data-apis/array-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。