Docstring says t.Tuple is supported, but typing.Tuple raises AttributeError
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 88/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Env の docstring がある envier/env.py の 232-233 行目から始めてください。そこでは t.Tuple が list や set と並んで記載されています。EnvVariable._cast(78-87 行目)と _check_type(28-32 行目)を読み、裸の typing.Tuple エイリアスに __args__ がないことを確認してください。最も簡単な修正は docstring を tuple に変えることです。別案として、typing.Tuple/List/Set を元の型に正規化します。既存の collection テストを実行し、正規化する場合は typing.Tuple のケースを追加してください。
索引モデルが issue の本文から書いたものです。
説明
The Env docstring says t.Tuple is supported as a collection type, but declaring a variable with typing.Tuple raises AttributeError when the value is read. The builtin tuple works.
Environment: envier 0.6.1, Python 3.12
Reproduction
import json
import typing
from envier import Env
try:
class C(Env):
x = Env.var(typing.Tuple, "x")
print(json.dumps(C({"X": "a,b"}).x))
except Exception as e:
print(json.dumps(type(e).__name__))
Actual output
"AttributeError"
Expected output
["a", "b"]
From the Env class docstring:
There is also basic support for collections. An item of type
list,t.Tupleorsetwill be parsed using,as item separator.
Likely cause: EnvVariable._cast only handles _type in (list, tuple, set), so typing.Tuple falls through to _check_type, which reads _type.__args__; the bare typing.Tuple alias has no __args__:
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L28-L32
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L78-L87
Since the same sentence lists the builtins list and set and the tests use builtin tuple, the simplest fix may be to change t.Tuple to tuple in the docstring; alternatively typing.Tuple (and typing.List/typing.Set) could be normalized to their origin types.
Found while testing the library with an automated exploration tool; the reproduction above was re-run on 0.6.1 before filing.
- 主要言語
- Python
- スター
- 9
- フォーク
- 2
- 平均マージ
- 7時間 22分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DataDog/envier のほかの issue
-
Add `examples`オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
Add `version_added`オープンenhancement
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OpenFreeEnergy/openfe#2371 ·
メンテナーはふだん 2 日以内に返信
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
NCATSTranslator/Babel#1269 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
404 on sample dataオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
twisted/incremental#214 ·