Skip to content

Add Nox as task runner #81

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

Merged
merged 5 commits into from
Jul 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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
omit =
**/__init__.py
noxfile.py
tests/*
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
.pre-commit-config.yaml
assets
LICENSE
noxfile.py
pyrightconfig.json
README.md
ruff.toml
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/pyright.yml → .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pyright
name: Format

on:
push:
Expand All @@ -7,14 +7,21 @@ on:
branches: [main]

jobs:
type-check:
ruff:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: jakebailey/pyright-action@v2
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }} with uv
uses: ./.github/actions/setup-python-with-uv
with:
python-version: ${{ matrix.python-version }}

- name: Format by Ruff
run: uv run nox -s fmt
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
pyright-and-ruff:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }} with uv
uses: ./.github/actions/setup-python-with-uv
with:
python-version: ${{ matrix.python-version }}

- name: Lint by Pyright and Ruff
run: uv run nox -s lint
46 changes: 0 additions & 46 deletions .github/workflows/ruff.yml

This file was deleted.

83 changes: 83 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from typing import Any

import nox
from pydantic_settings import BaseSettings


class CLIArgs(
BaseSettings,
cli_ignore_unknown_args=True,
):
"""CLIArgs is a class that extends BaseSettings to handle command line arguments."""

@classmethod
def parse(cls, posargs: list[str]) -> "CLIArgs":
"""Parse command line arguments from the provided list.

Args:
posargs (list[str]): List of positional arguments from the command line.

Returns:
CLIArgs: An instance of `CLIArgs` populated with the parsed arguments.

"""
arg_name: str | None = None
kwargs: dict[str, Any] = {}

for arg in posargs:
if arg.startswith("--"):
arg_name = arg[2:]
elif arg_name is not None:
kwargs[arg_name] = arg
arg_name = None

return cls(**kwargs)


@nox.session(python=False)
def fmt(session: nox.Session) -> None:
"""Format the code using Ruff.

Args:
session (nox.Session): The Nox session object.

Examples:
>>> uv run nox -s fmt

"""
session.run("uv", "run", "ruff", "format", ".")

session.log("✅ Formatting completed successfully.")


@nox.session(python=False)
def lint(session: nox.Session) -> None:
"""Lint the code using Pyright and Ruff.

Args:
session (nox.Session): The Nox session object.

Examples:
>>> uv run nox -s lint

"""
session.run("uv", "run", "pyright")
session.run("uv", "run", "ruff", "check", ".", "--fix")

session.log("✅ Linting completed successfully.")


@nox.session(python=False)
def test(session: nox.Session) -> None:
"""Run tests using pytest.

Args:
session (nox.Session): The Nox session object.

Examples:
>>> uv run nox -s test

"""
session.run("uv", "run", "pytest")

session.log("✅ Testing completed successfully.")
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dev-dependencies = [
"cookiecutter>=2.6.0",
"cookiecutter-data-science>=2.1.0",
"mkdocs-material>=9.5.50",
"nox>=2025.5.1",
"pre-commit>=4.1.0",
"pyright>=1.1.392.post0",
"pytest>=8.3.4",
Expand Down
Loading