This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| def load_env_vars(path: str) -> None: | |
| with open(path) as file: | |
| for line in file.readlines(): | |
| data = list(map(lambda v: v.strip(), line.split("="))) | |
| variable, value = data[0], data[1] | |
| os.environ[variable] = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, Self | |
| from .value_object import ValueObject | |
| class Entity[T: ValueObject]: | |
| """Base class for mutable entities (Entity) in the domain model. | |
| A mutable object that preserves its identity | |
| throughout its lifecycle, despite changes to its attributes. | |
| Every entity has the following properties: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass, fields | |
| from typing import Any, Self | |
| @dataclass(frozen=True, slots=True, repr=False) | |
| class ValueObject: | |
| def __new__(cls, *args: Any, **kwargs: Any) -> Self: | |
| if cls is ValueObject: | |
| raise Exception("ValueObject cannot be instantiated directly!") | |
| if not fields(cls): |