Type Checking for Class Row Factory
まだ誰も着手していません。
評価
調査の方向性
まず Issue #42 と PR #57 を確認してください。提案された解決策はそこに記載されています。次に comdb2.dataclasses.class_row_factory を調査し、BaseRowFactoryClass の例を、示されている型チェックに関する懸念と比較してください。完了とは、PR が dataclass 属性およびデータベース出力の検証に完全に対応しているかを確認することです。
索引モデルが issue の本文から書いたものです。
説明
As described in Issue #42 there was a proposed solution for having a Class Row Factory. Alongside the conversations happened there, there was a concern regarding type checking for the attributes of the class and output returned by the database. There doesn't seem to be a way to enforce type checking hence an extra __post_init__ method would be required within the class to enforce type checking. This can be overlooked by a lot of developers and can lead to a lot of type mismatches.
Solution
Define a Base class that our dataclasses can inherit. The Base class can have all the required methods for the validation etc.
The updated use of it can be described it here. The solution has been implemented on the PR #57
>>> from dataclasses import dataclass
>>> from comdb2.dataclasses.class_row_factory import BaseRowFactoryClass
...
>>> @dataclass
>>> class ABC(BaseRowFactoryClass):
>>> x: int
>>> y: int
...
>>> conn.row_factory = ClassRowFactory(ABC)
>>> row = conn.cursor().execute("select 1 as x, 2 as y").fetchone()
>>> print(row)
<>
>>> print(row.x)
- 主要言語
- Python
- スター
- 29
- フォーク
- 28
- 平均マージ
- 11時間 25分
- マージ済み PR(30日)
- 2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bloomberg/python-comdb2 のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
bloomberg/python-comdb2#80 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
bloomberg/python-comdb2#61 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
bloomberg/python-comdb2#42 · コメント 14 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
bloomberg/python-comdb2#41 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bloomberg/python-comdb2#36 · コメント 1 件 ·
bloomberg/python-comdb2 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main オープンarea: ci bug perceived difficulty: 3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-connect#1057 ·