google / google/python-spanner-orm

Re-write Model to use dataclasses.

オープン
#97 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
41
フォーク
17
PR マージ指標
30日以内にマージされた PR はありません

説明

`Model` currently uses a metaclass (which is disallowed by the style guide for good reasons) and `Field`s which make type checking tricky. (The class attribute is of type `Field`, but the instance attribute with the same name is of type `str`, `int`, or whatever that specific field stores.) I think most of this could be solved by switching to something based on `dataclasses`. E.g., in Python 3.9+:

```python
@dataclasses.dataclass
class Foo(spanner_orm.Model):
foo: Annotated[int, spanner_orm.primary_key]
```

Or in older versions of Python:
```python
@dataclasses.dataclass
class Foo(spanner_orm.Model):
foo: int = dataclasses.field(metadata={spanner_orm.PRIMARY_KEY: True})
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。