Preconfigured union for a "plain" python data structures
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 :)
- Lingua principale
- Python
- Stelle
- 1.1k
- Fork
- 159
- Merge medio
- 12h 21m
- PR unite (30g)
- 6
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-attrs/cattrs
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-attrs/cattrs#761 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
python-attrs/cattrs#513 · 4 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
python-attrs/cattrs#779 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 85/100
python-attrs/cattrs#774 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
python-attrs/cattrs#746 · 2 commenti ·
Tutte le issue di python-attrs/cattrs
Issue simili
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
simonw/sqlite-utils#872 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100