Skip to content

Remove the conditional usage of slots #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/jobs/assembler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,44 @@

from jobs.types import AnyPath

# To support slots keyword in Python < 3.10, see https://stackoverflow.com/questions/72733998/kw-only-and-slots-dataclass-compatibility-with-older-versions-of-python
SLOTS_DATACLASS = dict(slots=True) if "slots" in dataclass.__kwdefaults__ else {}


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class DependencySpec:
apt: list[str]
pip: list[str]


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class VolumeSpec:
host_path: str
container_path: str


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class FilesystemSpec:
copy: list[dict[str, str]] = field(default_factory=list)
add: list[dict[str, str]] = field(default_factory=list)


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class ConfigSpec:
env: list[dict[str, str]] = field(default_factory=list)
arg: list[dict[str, str]] = field(default_factory=list)
stopsignal: str | None = None
shell: str | None = None


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class MetaSpec:
labels: list[dict[str, str]]


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class UserSpec:
name: str


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class BuildSpec:
base_image: str
dependencies: DependencySpec | None = None
Expand Down Expand Up @@ -80,7 +77,7 @@ def _coerce_spec(val, spec):
object.__setattr__(self, attr, coerced_value)


@dataclass(frozen=True, **SLOTS_DATACLASS)
@dataclass(frozen=True)
class Config:
build: BuildSpec

Expand Down