-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nox and github action for code formatting & type checking
- Loading branch information
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Format & Type Check | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
formatting: | ||
runs-on: ubuntu-latest | ||
name: "Check code style" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Run ruff via nox | ||
run: | | ||
python -m pip install nox | ||
python -m nox -s format | ||
pyright: | ||
runs-on: ubuntu-latest | ||
name: "Type checking" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Run pyright via nox | ||
run: | | ||
python -m pip install nox | ||
python -m nox -s pyright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
import nox | ||
from nox import options | ||
|
||
PROJECT_PATH = os.path.join(".", "src") | ||
SCRIPT_PATHS = [PROJECT_PATH, "noxfile.py"] | ||
|
||
options.sessions = ["format_fix", "pyright"] | ||
|
||
|
||
@nox.session() | ||
def format_fix(session: nox.Session) -> None: | ||
session.install("-r", "requirements_dev.txt") | ||
session.run("python", "-m", "ruff", "format", *SCRIPT_PATHS) | ||
session.run("python", "-m", "ruff", "check", *SCRIPT_PATHS, "--fix") | ||
|
||
|
||
@nox.session() | ||
def format_check(session: nox.Session) -> None: | ||
session.install("-r", "requirements_dev.txt") | ||
session.run("python", "-m", "ruff", "format", *SCRIPT_PATHS, "--check") | ||
session.run("python", "-m", "ruff", "check", *SCRIPT_PATHS) | ||
|
||
|
||
@nox.session() | ||
def pyright(session: nox.Session) -> None: | ||
session.install("-r", "requirements_dev.txt", "-r", "requirements.txt") | ||
session.run("pyright", *SCRIPT_PATHS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
ruff==0.7.3 | ||
nox==2024.10.9 | ||
ruff==0.9.1 | ||
pre-commit==4.0.1 | ||
pyright==1.1.391 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters