diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 3294538..aa5fefd 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -21,10 +21,14 @@ jobs: run: poetry --help - name: Run poetry install run: poetry install - - name: Run tests - run: poetry run pytest tests - - name: Run black - run: poetry run black l9format/*.py tests/*.py --check - - name: Run poetry build - run: poetry build + - name: lint + run: poetry run ruff check . + - name: format check + run: poetry run black --check . + - name: sort-check + run: poetry run isort --check-only . + - name: test + run: poetry run pytest + - name: security-audit + run: poetry run pip-audit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dbbf7a8 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +# Makefile for pygins project + +.PHONY: test format sort lint security-check all + +# Run all quality checks +all: test format sort lint security-check + +# Run tests using pytest +test: + poetry run pytest + +# Format code using black +format: + poetry run black . + +# Sort imports using isort +sort: + poetry run isort . + +# Lint code using ruff +lint: + poetry run ruff check . + +# Check for vulnerable dependencies using pip-audit +security-check: + poetry run pip-audit + diff --git a/l9format/l9format.py b/l9format/l9format.py index 1e0ff20..3cecca7 100644 --- a/l9format/l9format.py +++ b/l9format/l9format.py @@ -1,6 +1,8 @@ import decimal + from serde import Model, fields + # Import from https://github.com/rossmacarthur/serde/commit/304884bca3c80e8b9a22a054b64dd94e3324b593#diff-dd2f65f16516311f0183377201a3d0b7894438787da732fc2bbc9c28cbde9fb8 # A helper function... def round_decimal( @@ -48,7 +50,7 @@ def deserialize(self, value) -> decimal.Decimal: return decimal.Decimal(value) except decimal.DecimalException: - raise ValidationError("invalid decimal", value=value) + raise Exception("invalid decimal", value=value) class L9HttpEvent(Model): diff --git a/pyproject.toml b/pyproject.toml index 8a1283c..6dae6c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,10 +19,13 @@ python = "^3.9" # Bump up to python 3.11 fixes the issue as it seems fixed in the stdlib of 3.11 serde = "^0.8.1" -[tool.poetry.dev-dependencies] -pytest = "*" -black = "^22" -mypy = "*" +[tool.poetry.group.dev.dependencies] +black = "^24.10.0" +fire = "^0.7.0" +isort = "^5.12.0" +pip-audit = "^2.7.3" +pytest = "^8.3.4" +ruff = "^0.9.2" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/test_l9format.py b/tests/test_l9format.py index 67c9762..443ba80 100644 --- a/tests/test_l9format.py +++ b/tests/test_l9format.py @@ -1,7 +1,8 @@ -from l9format import l9format -from pathlib import Path -import os import json +import os +from pathlib import Path + +from l9format import l9format TESTS_DIR = Path(os.path.dirname(__file__))