Skip to content

Tagging relies on class names exclusively #742

Description

@magreenberg1

Hi again!

I currently have some code like...

@serde(tagging=InternalTagging("type"))
@dataclass(frozen=True, kw_only=True)
class ConfigFile:
    items: list[ConfigA | ConfigB]

As far as I can tell, in the config file, items[].type must be either "ConfigA" or "ConfigB" but I'd like to use "A" or "B" in the config file instead. Perhaps we can add a mapping in the Tagging types so we can expect custom values?

Something like...

@serde(tagging=InternalTagging("type", tag_types={"A": ConfigA, "B": ConfigB}))
@dataclass(frozen=True, kw_only=True)
class ConfigFile:
    items: list[ConfigA | ConfigB]

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions