Skip to content

Commit cecfb0a

Browse files
authored
Merge pull request #81 from a5chin/feature/nox
Add Nox as task runner
2 parents b4ee41a + 20293dc commit cecfb0a

File tree

8 files changed

+828
-691
lines changed

8 files changed

+828
-691
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[run]
22
omit =
3+
**/__init__.py
34
noxfile.py
45
tests/*

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
.pre-commit-config.yaml
183183
assets
184184
LICENSE
185+
noxfile.py
185186
pyrightconfig.json
186187
README.md
187188
ruff.toml
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pyright
1+
name: Format
22

33
on:
44
push:
@@ -7,14 +7,21 @@ on:
77
branches: [main]
88

99
jobs:
10-
type-check:
10+
ruff:
1111
runs-on: ubuntu-latest
1212

1313
strategy:
1414
matrix:
1515
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1616

1717
steps:
18-
- uses: jakebailey/pyright-action@v2
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python ${{ matrix.python-version }} with uv
22+
uses: ./.github/actions/setup-python-with-uv
1923
with:
2024
python-version: ${{ matrix.python-version }}
25+
26+
- name: Format by Ruff
27+
run: uv run nox -s fmt

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
pyright-and-ruff:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python ${{ matrix.python-version }} with uv
22+
uses: ./.github/actions/setup-python-with-uv
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Lint by Pyright and Ruff
27+
run: uv run nox -s lint

.github/workflows/ruff.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

noxfile.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from typing import Any
2+
3+
import nox
4+
from pydantic_settings import BaseSettings
5+
6+
7+
class CLIArgs(
8+
BaseSettings,
9+
cli_ignore_unknown_args=True,
10+
):
11+
"""CLIArgs is a class that extends BaseSettings to handle command line arguments."""
12+
13+
@classmethod
14+
def parse(cls, posargs: list[str]) -> "CLIArgs":
15+
"""Parse command line arguments from the provided list.
16+
17+
Args:
18+
posargs (list[str]): List of positional arguments from the command line.
19+
20+
Returns:
21+
CLIArgs: An instance of `CLIArgs` populated with the parsed arguments.
22+
23+
"""
24+
arg_name: str | None = None
25+
kwargs: dict[str, Any] = {}
26+
27+
for arg in posargs:
28+
if arg.startswith("--"):
29+
arg_name = arg[2:]
30+
elif arg_name is not None:
31+
kwargs[arg_name] = arg
32+
arg_name = None
33+
34+
return cls(**kwargs)
35+
36+
37+
@nox.session(python=False)
38+
def fmt(session: nox.Session) -> None:
39+
"""Format the code using Ruff.
40+
41+
Args:
42+
session (nox.Session): The Nox session object.
43+
44+
Examples:
45+
>>> uv run nox -s fmt
46+
47+
"""
48+
session.run("uv", "run", "ruff", "format", ".")
49+
50+
session.log("✅ Formatting completed successfully.")
51+
52+
53+
@nox.session(python=False)
54+
def lint(session: nox.Session) -> None:
55+
"""Lint the code using Pyright and Ruff.
56+
57+
Args:
58+
session (nox.Session): The Nox session object.
59+
60+
Examples:
61+
>>> uv run nox -s lint
62+
63+
"""
64+
session.run("uv", "run", "pyright")
65+
session.run("uv", "run", "ruff", "check", ".", "--fix")
66+
67+
session.log("✅ Linting completed successfully.")
68+
69+
70+
@nox.session(python=False)
71+
def test(session: nox.Session) -> None:
72+
"""Run tests using pytest.
73+
74+
Args:
75+
session (nox.Session): The Nox session object.
76+
77+
Examples:
78+
>>> uv run nox -s test
79+
80+
"""
81+
session.run("uv", "run", "pytest")
82+
83+
session.log("✅ Testing completed successfully.")

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dev-dependencies = [
2121
"cookiecutter>=2.6.0",
2222
"cookiecutter-data-science>=2.1.0",
2323
"mkdocs-material>=9.5.50",
24+
"nox>=2025.5.1",
2425
"pre-commit>=4.1.0",
2526
"pyright>=1.1.392.post0",
2627
"pytest>=8.3.4",

0 commit comments

Comments
 (0)