Make a Converter without the default hook factories
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
The payload names no files. Start with the fallback-hook-factories section of the docs and the unstructure_fallback_factory and structure_fallback_factory arguments of Converter, to see how a child converter consults its parent. Then check why the default structure_attrs_fromdict preference overrides the parent's hook. The issue is open on which approach to take (a BaseConverter workaround or new __init__ flags), so agree on a design with maintainers first. Done means a child converter uses a hook registered on its parent even when a default hook exists.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The problem
Let's take the fallback-hook-factories section
parent = Converter()
child = Converter(
unstructure_fallback_factory=parent.get_unstructure_hook,
structure_fallback_factory=parent.get_structure_hook,
)
Let's say in parent you added another custom hook factory such as
@parent.register_structure_hook_factory(lambda val: issubclass(val, Foo))
def structure_Foo(cls) -> StructureHook:
...
You would expect that the child would pick up this new converter of the parent, but that is not the case if there is already a way to structure Foo from the default converters in Converter
So what now?
One way around this is to use BaseConverter I guess, but it is not quite that straightforward and trying it out I still hit some other preferences that override it, e.g. structure_attrs_fromdict.
Another option would be to have flags in the __init__ of those converters to truely not add any defaults and let it fallback to the parent more directly.
- Lingua principale
- Python
- Stelle
- 1.1k
- Fork
- 171
- Merge medio
- 14h 46m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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
-
Dataclass default_factory field treated as required in union disambiguationForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-attrs/cattrs#796 ·
I maintainer di solito rispondono entro 1 giorno
-
decimal.Decimal not handled in preconf converters (json, pyyaml)Forse già presa @Binilkks l’ha presa 112 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-attrs/cattrs#761 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
python-attrs/cattrs#513 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Structure hook on a PEP 695 alias is ignored inside a passthrough unionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
python-attrs/cattrs#797 ·
I maintainer di solito rispondono entro 1 giorno
-
msgspec converter skips hooks and drops private fields in nested recursionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 64/100
python-attrs/cattrs#795 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di python-attrs/cattrs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ok-oldking/ok-wuthering-waves#1785 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
healthchecks/healthchecks#1349 ·
-
deployment release-lag
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
nolte/kamerplanter#2374 ·
I maintainer di solito rispondono entro 1 giorno
-
bug v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/python-sdk#3725 ·
I maintainer di solito rispondono entro 1 giorno
-
batchterms() drops queries without a similar() clause, misaligning results with inputsForse già presa @MohammadHijjawi97 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno