Skip to content

Commit

Permalink
Merge pull request #124 from rom-py/forbid-extra
Browse files Browse the repository at this point in the history
Forbid extra
  • Loading branch information
tomdurrant authored Nov 13, 2024
2 parents c05b280 + c9189e7 commit 6b8cb4b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rompy/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class RompyBaseModel(BaseModel):
# The config below prevents https://github.com/pydantic/pydantic/discussions/7121
model_config = ConfigDict(protected_namespaces=())
model_config = ConfigDict(protected_namespaces=(), extra="forbid")


class Latitude(BaseModel):
Expand Down Expand Up @@ -312,6 +312,7 @@ class DatasetCoords(RompyBaseModel):
x: Optional[str] = Field("longitude", description="Name of the x coordinate")
y: Optional[str] = Field("latitude", description="Name of the y coordinate")
z: Optional[str] = Field("depth", description="Name of the z coordinate")
s: Optional[str] = Field("site", description="Name of the site coordinate")


class Slice(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion rompy/schism/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def outfile(self) -> str:

@property
def namelist(self) -> dict:
ret = self.model_dump()
# ret = self.model_dump()
ret = {}
for key, value in self.model_dump().items():
if key in ["relative_weight", "max_window_hours", "fail_if_missing"]:
ret.update({f"{self.id}_{key}": value})
Expand Down
2 changes: 1 addition & 1 deletion rompy/swan/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def grid(
"""
return SwanGrid(
gridtype="REG",
grid_type="REG",
x0=float(self._obj[x].min()),
y0=float(self._obj[y].min()),
dx=float(np.diff(self._obj[x]).mean()),
Expand Down
1 change: 0 additions & 1 deletion tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def test_custom_template(tmpdir):
runtime = ModelRun(
run_id="test_base",
output_dir=str(tmpdir),
template="simple_templates/base",
config=config,
)
runtime.generate()
Expand Down

0 comments on commit 6b8cb4b

Please sign in to comment.