Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Dec 11, 2024
1 parent 8ac4ade commit 5ffb5d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/aind_data_schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ class AindCoreModel(AindModel):
@field_validator("schema_version", mode="before")
@classmethod
def coerce_version(cls, v: str) -> str:
"""Update the schema version to the latest version
"""
"""Update the schema version to the latest version"""
return get_args(cls.model_fields["schema_version"].annotation)[0]

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ def test_ccf_validator(self):

class StructureModel(AindModel):
"""Test model with a targeted_structure"""

targeted_structure: CCFStructure.ONE_OF

self.assertRaises(ValueError, StructureModel, targeted_structure="invalid")

def test_schema_bump(self):
"""Test that schema version are bumped successfully
and that validation errors prevent bumping"""

class Modelv1(AindCoreModel):
describedBy: str = "modelv1"
schema_version: SkipValidation[Literal["1.0.0"]] = "1.0.0"
Expand All @@ -138,9 +140,7 @@ class Modelv2(AindCoreModel):
v1_init = Modelv1()
self.assertEqual("1.0.0", v1_init.schema_version)

v2_from_v1 = Modelv2(
**v1_init.model_dump()
)
v2_from_v1 = Modelv2(**v1_init.model_dump())
self.assertEqual("1.0.1", v2_from_v1.schema_version)

# Check that adding additional fields still fails validation
Expand Down

0 comments on commit 5ffb5d9

Please sign in to comment.