Removing Schema context feels like a bad idea!
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia leggendo l’issue #2707 e la pull request a cui fa riferimento, quindi confronta la documentazione attuale del contesto v4 con gli esempi di self.context descritti qui. Determina se il contesto passato alle chiamate dump/load o tramite un context manager è supportato e registra la sostituzione o la decisione prevista dal progetto per l’onere di migrazione segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Maybe this is subjective, but it feels like the removal of context makes previously simple tasks much more cumbersome and verbose...
Correct my if I'm wrong, but it looks like you expect context to be completely handled outside marshmallow using basically global variables (yes, I know, contextvars are better than that, but both are similarly "loose").
For example, quite a few schemas require access to user for which the dumping happens, e.g. to filter out certain data post-dump or to include information on whether the user can do certain operations with the object being dumped. In both cases, I've been using MySchema(context={'user': session.user}) so the schema itself is agnostic to request state - any user could be passed in via the schema, not necessarily the currently logged-in user. Inside the schema it was trivial to use self.context[...] in Method fields or hooks.
Now, however, unless I'm missing something, ALL this functionality is gone, and I'm expected to create a new class for the context, and import it both for passing context and for receiving it (YAY for circular import issues, they were already bad enough before especially when using SQLAlchemy model schemas). It all becomes much more verbose.
A simple self.context['user'] to access it vs something like Context[UserContext].get()['user'] or Context[UserContext].get() (haven't actually tested v4 yet, so not sure how exactly it works).
And honestly, I'm absolutely not looking forward to fixing over 50 occurrences of self.context plus roughly the same number of places where it's being passed to a schema...
The description of #2707 still mentions that "Context can be passed in dump/load call or set in a context manager" but I can't see this in the docs nor the PR's code. So this never happened I guess?
- Lingua principale
- Python
- Stelle
- 7.2k
- Fork
- 790
- Merge medio
- 10h 40m
- PR unite (30g)
- 6
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 marshmallow-code/marshmallow
-
ContainsOnly raises TypeError for unhashable input with set-based choicesForse già presa @prathamchoksi l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
marshmallow-code/marshmallow#3115 ·
I maintainer di solito rispondono entro 1 giorno
-
`validate.Email` accepts a leading/trailing hyphen in the last domain labelForse già presa @syahra712 l’ha presa 35 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
marshmallow-code/marshmallow#3072 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 68/100
marshmallow-code/marshmallow#3068 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Negative POSIX timestamps cannot be deserialized after timestamp serializationForse già presa @lafrech l’ha presa 90 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
marshmallow-code/marshmallow#3019 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
SchemaOpts misses partialForse già presa @number492 l’ha presa 489 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
marshmallow-code/marshmallow#2834 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di marshmallow-code/marshmallow
Issue simili
-
area:security effort:S priority:P3 status:needs-triage type:chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
randomparity/kdive#3657 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
aws/mcp-proxy-for-aws#476 ·
I maintainer di solito rispondono entro 1 giorno
-
fix(cli): a --root that does not exist exits 0 with 'Scanned 0 file(s)', so a wrong path in CI passes silentlyForse già presa @arpanjot-coding l’ha presa oggi. Apertaarea: runtime automation bug cli code-scanning consistency developer-experience difficulty: easy github-actions good first issue help wanted json-output priority: P3 python sarif silent-failure static-analysis tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno