Preconfigured union for a "plain" python data structures
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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 :)
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 159
- Avg merge
- 12h 21m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-attrs/cattrs
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
python-attrs/cattrs#761 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
python-attrs/cattrs#513 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
python-attrs/cattrs#779 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 85/100
python-attrs/cattrs#774 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
python-attrs/cattrs#746 · 2 comments ·
All issues in python-attrs/cattrs
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·