From 60ee697a49a1a20a3d0a555163cb8ad1da7ec3ae Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 23 Jan 2025 20:50:05 +0100 Subject: [PATCH 1/5] Update dev deps --- pyproject.toml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8a1283c..5206ce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,10 +19,14 @@ 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" +mypy = "^1.5.0" +pip-audit = "^2.7.3" +pytest = "^8.3.4" +ruff = "^0.9.2" [build-system] requires = ["poetry-core>=1.0.0"] From 285fe96c5ab9afdd8a0e4ee8a280cc0637fa11b7 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 23 Jan 2025 20:52:53 +0100 Subject: [PATCH 2/5] Use Exception instead of undefined ValidationError --- l9format/l9format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l9format/l9format.py b/l9format/l9format.py index 1e0ff20..7dad869 100644 --- a/l9format/l9format.py +++ b/l9format/l9format.py @@ -48,7 +48,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): From b5e774b3228c4b459bb1419ef06dc8b42d0d18c4 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 23 Jan 2025 20:53:23 +0100 Subject: [PATCH 3/5] Pyproject: stop using mypy --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5206ce2..6dae6c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ serde = "^0.8.1" black = "^24.10.0" fire = "^0.7.0" isort = "^5.12.0" -mypy = "^1.5.0" pip-audit = "^2.7.3" pytest = "^8.3.4" ruff = "^0.9.2" From 7be862509f25c686fd67cb3aa06eec336fc4200d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 23 Jan 2025 20:54:09 +0100 Subject: [PATCH 4/5] Add Makefile and run make all --- Makefile | 27 +++++++++++++++++++++++++++ l9format/l9format.py | 2 ++ tests/test_l9format.py | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Makefile 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 7dad869..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( 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__)) From f3f9ebd32032fef8d5cf787981fc0f1475e6d4a3 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Thu, 23 Jan 2025 20:55:46 +0100 Subject: [PATCH 5/5] CI: add new checks according to Makefile --- .github/workflows/action.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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