Skip to content

Commit

Permalink
Pydantic V2 migration (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Manz <[email protected]>
  • Loading branch information
nvictus and manzt authored Nov 11, 2024
1 parent cc66891 commit a14c66a
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
node-version: '20.x'
- run: npm install -g ajv-cli
- run: ajv validate -s schema.json -d "tests/fixtures/{docs/examples/viewconfs,test/{view-configs,view-configs-more}}/*.json"
- run: ajv validate --spec=draft2020 -s schema.json -d "tests/fixtures/{docs/examples/viewconfs,test/{view-configs,view-configs-more}}/*.json"

Test:
name: Test ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.8"
dynamic = ["version"]
dependencies = ["pydantic>=1.10,<2.0", "rich>=13.0.0"]
dependencies = ["pydantic>=2.0", "rich>=13.0.0"]

[project.urls]
homepage = "https://github.com/higlass/higlass-schema"
Expand Down
6 changes: 4 additions & 2 deletions src/higlass_schema/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def check(args: argparse.Namespace) -> None:
try:
if args.path == "-":
raw = "\n".join(sys.stdin.readlines())
Viewconf[View[Track]].parse_raw(raw)
Viewconf[View[Track]].model_validate_json(raw)
else:
Viewconf[View[Track]].parse_file(args.path)
with open(args.path) as file:
raw = file.read()
Viewconf[View[Track]].model_validate_json(raw)
console.print("✅ valid viewconf.", style="green")
except ValidationError:
msg = "❌ Invalid viewconf."
Expand Down
Loading

0 comments on commit a14c66a

Please sign in to comment.