Skip to content
Discussion options

You must be logged in to vote

Hi @bramp! Yes — you can achieve this by defining a shared base class with the desired Meta configuration, and then subclassing it for each of your dataclasses. This lets you centralize the configuration without repeating it on every class.

Here’s a simple example using the v1 opt-in:

from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
from pprint import pp

from dataclass_wizard import JSONWizard, LoadMeta, fromdict


class BaseConfig(JSONWizard):
    class _(JSONWizard.Meta):
        v1 = True
        v1_on_unknown_key = 'RAISE'


@dataclass
class ProfileModel(BaseConfig):
    id: UUID
    name: str
    created_at: datetime


profile_json_msg = {
    "p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bramp
Comment options

Answer selected by rnag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants