Feature request: "flatten" operation for cattrs.gen
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Start by reading the existing override function and the make_dict_structure_fn and make_dict_unstructure_fn entry points. Trace how field overrides are applied in both directions, then define the flatten behavior around the provided A and C example. Done means the proposed flatten option works for structure and unstructure while preserving existing behavior by default.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
For a thing at work, I implemented some [un]structure hook factories that wrap make_dict_structure_fn and make_dict_unstructure_fn to support flattening an attribute, like this:
@define
class A:
a: int
b: int
@define
class C:
a: A
c: int
converter = ... # set up a converter with my wrappers
assert converter.unstructure(C(A(1, 2), 3)) == {'a': 1, 'b': 2, 'c': 3}
I'd like to upstream this support. The basic idea is to implement functionality similar to Serde's Struct flattening by extending the override function to take a flatten: bool argument that defaults to False and then adjusting make_dict_structure_fn and make_dict_unstructure_fn to use it.
I'm willing to work on this, but wanted to get feedback from folks here before I start.
- Langage dominant
- Python
- Étoiles
- 1.1k
- Forks
- 165
- Merge moyen
- 11 h 51 min
- PR mergées (30 j)
- 7
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-attrs/cattrs
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
python-attrs/cattrs#761 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
python-attrs/cattrs#513 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Literal discriminator ignores override(rename=...), so union structuring fails with KeyErrorOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
python-attrs/cattrs#779 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 85/100
python-attrs/cattrs#774 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
python-attrs/cattrs#746 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de python-attrs/cattrs
Issues similaires
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
workflow: a tick's dispatch counts as 'only this step', and no review self-grants a round unattendedOuverteworkflow
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
kristofdegrave/homeassistant-smart-charging#1505 ·
Les mainteneurs répondent en général sous 1 jour
-
New Submission: TropWATEROuvertemetadata submission
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Wrongly named dashboard variableOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
canonical/content-cache-operator#163 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[submission]Ouvertesubmission
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
leanprover/lean-eval-submissions#1852 ·
Les mainteneurs répondent en général sous 1 jour