python-desert
python-desert
After a brief look, I think polyfield is focused on unioning over schemas, not other types. So while that'd work fine in the example above, it'd be awkward in the...
If I'm thinking about this right we need ```py class AdjacentlyTaggedUnion(marshmallow.fields.Field): ... class ExternallyTaggedUnion(marshmallow.fields.Field): ... class InternallyTaggedUnion(marshmallow.fields.Field): ... class UntaggedUnion(marshmallow.fields.Field): ... ``` and to pick a default for what `typing.Union`...
@sveinse > Shouldn't really these fields belong in marshmallow or a variant thereof? It could make sense to put these changes in a more narrowly marshmallow-focused library. `marshmallow-union` could be...
Let's talk interface. ```py thing: Union[A, B] ``` will be treated like ```py thing: Union[A, B] = AdjacentlyTaggedUnion(...) ``` What's the signature? Edit: removed comments that didn't make sense.
As I mentioned above, I think we want to diverge from polyfield in that all of those "schema"s in @altendky's bullet list should be fields for us. That way we...
Suppose we're doing this for marshmallow independent of the dataclass logic. Do we allow ```py AdjacentlyTaggedUnion([AField(), BField()], ...) ``` or only ```py AdjacentlyTaggedUnion({'A': AField(), 'B': BField()}, ...) ```
Eh let's start with the latter, we can always add more stuff if we want to.
A concrete implementation of `AdjacentlyTaggedUnion` will probably give us more to talk about. Anybody interested in taking a crack at it?
I don't think we want to mutate our argument. We could add some tests to make sure that we don't mutate it. If we're confident that we're not mutating it...
Saving some links for future readers: - https://cosmicpercolator.com/2016/01/16/mutable-default-arguments-are-your-friend/ - https://bugs.python.org/issue38654