Preconfigured union for a "plain" python data structures
まだ誰も着手していません。
評価
調査の方向性
Review the existing preconfigured converters and PythonConverter configuration to identify the entry point for adding another preset. Use the proposed plain Python passthrough types and collection overrides as the acceptance criteria, then verify that the new converter preserves those values and collections during conversion.
索引モデルが issue の本文から書いたものです。
説明
There are preconfigured converters for the various serialization formats, but I have found need for a converter specific to what I will call "plain" Python.
Basically:
PassThroughTypes: TypeAlias = str | bool | int | float | bytes | None
def python_make_converter(
*args: Any,
**kwargs: Any,
) -> PythonConverter:
# configure specific overrides for this converter
kwargs["unstruct_collection_overrides"] = {
# rich built-in types are maintained, rather than all dumped
# into lists
Sequence: tuple,
MutableSequence: list,
Set: frozenset,
MutableSet: set,
Counter: lambda c: Counter(**{k: v for k, v in c}),
}
converter = PythonConverter(*args, **kwargs)
# passthrough union types
configure_union_passthrough(PassThroughTypes, converter)
return converter
Just some context for what I am doing that warranted making this concrete versus the more plain cattrs.global_converter. I am using the converter to generate "patches" that all happens within Python and the above to be very useful.
I would propose that a new preconfigured converter be made similar to the others. But I can understand it not being high priority, in which case this issue may help someone else :)
- 主要言語
- Python
- スター
- 1.1k
- フォーク
- 159
- 平均マージ
- 12時間 21分
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-attrs/cattrs のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-attrs/cattrs#761 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
python-attrs/cattrs#513 · コメント 4 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
python-attrs/cattrs#779 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 85/100
python-attrs/cattrs#774 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
python-attrs/cattrs#746 · コメント 2 件 ·
python-attrs/cattrs の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100