Skip to content

Commit 3c59906

Browse files
tamirseclaude
andcommitted
drop infer_missing=True from Volume.from_dict calls
All optional fields already have defaults on the dataclass, so infer_missing is unnecessary. Removing it gives stricter validation: a response missing a required field like id or name will raise immediately instead of silently setting None. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a8622e6 commit 3c59906

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/unit_tests/volumes/test_volumes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_from_dict_without_optional_fields(self):
144144
'instance_id': None,
145145
'ssh_key_ids': [],
146146
}
147-
volume = Volume.from_dict(minimal_dict, infer_missing=True)
147+
volume = Volume.from_dict(minimal_dict)
148148
assert volume.id == RANDOM_VOL_ID
149149
assert volume.pseudo_path is None
150150
assert volume.mount_command is None

verda/volumes/_volumes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def create_from_dict(cls, volume_dict: dict) -> 'Volume':
6767
6868
.. deprecated:: Use :meth:`from_dict` instead.
6969
"""
70-
return cls.from_dict(volume_dict, infer_missing=True)
70+
return cls.from_dict(volume_dict)
7171

7272

7373
class VolumesService:
@@ -85,7 +85,7 @@ def get(self, status: str | None = None) -> list[Volume]:
8585
:rtype: list[Volume]
8686
"""
8787
volumes_dict = self._http_client.get(VOLUMES_ENDPOINT, params={'status': status}).json()
88-
return [Volume.from_dict(v, infer_missing=True) for v in volumes_dict]
88+
return [Volume.from_dict(v) for v in volumes_dict]
8989

9090
def get_by_id(self, id: str) -> Volume:
9191
"""Get a specific volume by its.
@@ -97,7 +97,7 @@ def get_by_id(self, id: str) -> Volume:
9797
"""
9898
volume_dict = self._http_client.get(VOLUMES_ENDPOINT + f'/{id}').json()
9999

100-
return Volume.from_dict(volume_dict, infer_missing=True)
100+
return Volume.from_dict(volume_dict)
101101

102102
def get_in_trash(self) -> list[Volume]:
103103
"""Get all volumes that are in trash.
@@ -107,7 +107,7 @@ def get_in_trash(self) -> list[Volume]:
107107
"""
108108
volumes_dicts = self._http_client.get(VOLUMES_ENDPOINT + '/trash').json()
109109

110-
return [Volume.from_dict(v, infer_missing=True) for v in volumes_dicts]
110+
return [Volume.from_dict(v) for v in volumes_dicts]
111111

112112
def create(
113113
self,

0 commit comments

Comments
 (0)