Use @dataclass in my project. Now I want to implement @dataclass for PATCH method(partial_update) and initialize only provided arguments.
For example:
@dataclass
class Person:
id: int
first_name: Optional[str]
last_name: Optional[str]
birthday: Optional[datetime.date]
and use it like:
person = Person(id=1, first_name ='Andrew')
so now person have only two arguments id and first_name(person.id, person.first_name
)
Does someone have understanding how to implement such stuff? maybe is some wrapper for @dataclass?
P.S. Can't use
@dataclass
class Person:
id: int
first_name: Optional[str] = None
last_name: Optional[str] = None
birthday: Optional[datetime.date] = None
because it will provide None to not provided arguments and it will update fields in database with None.
I don't want these fields be updated in database, so I don't need them being initialized in dataclass.