Skip to content

Commit 29d2012

Browse files
committed
Use defaults for non-positive camera values
Update CameraSettings.apply_defaults to treat None or non-positive numeric values as "use default". The code now reads the field value first and replaces it with the default if value is None or (isinstance int/float and value <= 0), and adds a comment noting this represents an "auto" behavior with a TODO to consider a clearer representation.
1 parent 47522a7 commit 29d2012

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dlclivegui/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ def from_defaults(cls) -> CameraSettings:
6969
def apply_defaults(self) -> CameraSettings:
7070
default = self.from_defaults()
7171
for field in CameraSettings.model_fields:
72-
if getattr(self, field) in (None, 0, 0.0):
72+
value = getattr(self, field)
73+
if value is None or (isinstance(value, (int, float)) and value <= 0):
74+
# auto means use default value
75+
# TODO @C-Achard
76+
# Consider a more explicit way to represent "use default" vs "explicitly disable/zero out"
7377
setattr(self, field, getattr(default, field))
7478
return self
7579

0 commit comments

Comments
 (0)