Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev deps + better CI #8

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

4 changes: 3 additions & 1 deletion l9format/l9format.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 4 additions & 3 deletions tests/test_l9format.py
Original file line number Diff line number Diff line change
@@ -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__))

Expand Down