Skip to content

Commit 63855d5

Browse files
committed
Make dataclass frozen
This will mean that post_init is called if anyone later modifies the attributes of the dataclass. This ensure validation always
1 parent f5c21d8 commit 63855d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/atip/simulator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LinoptType(StrEnum):
1919
LINOPT6 = auto()
2020

2121

22-
@dataclass
22+
@dataclass(frozen=True)
2323
class SimParams:
2424
linopt: LinoptType = LinoptType.LINOPT6
2525
emittance: bool = True
@@ -34,7 +34,7 @@ def __post_init__(self):
3434
"Emittance and radiation calculations must be disabled when using "
3535
f"{self.linopt}",
3636
)
37-
if self.linopt == LinoptType.LINOPT6:
37+
elif self.linopt == LinoptType.LINOPT6:
3838
if not self.radiation and self.emittance:
3939
raise ValueError(
4040
"You cannot calculate emittance with radiation disabled",

0 commit comments

Comments
 (0)