Skip to content

Instantly share code, notes, and snippets.

@cassioeskelsen
Last active June 12, 2021 15:27
Show Gist options
  • Select an option

  • Save cassioeskelsen/1e80ac66eb2b0cc2c3b72517cb623e54 to your computer and use it in GitHub Desktop.

Select an option

Save cassioeskelsen/1e80ac66eb2b0cc2c3b72517cb623e54 to your computer and use it in GitHub Desktop.
@dataclass(eq=True)
class Customer:
name: str
address: Address
document: str
insert_date: datetime = field(default_factory=datetime.datetime.now)
Id: str = None
def __hash__(self) -> int:
return hash(self.Id)
def get_customer(key, value):
if not value:
return None
elif key == "state":
return State(**value)
elif key == "address" and not isinstance(value, str):
return Address(**value)
elif key in ['insert_date']:
return dateutil.parser.isoparse(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment