build: switch pre-commit completely to nox
This commit is contained in:
parent
deedac2a2e
commit
97e90271c4
2 changed files with 57 additions and 60 deletions
|
|
@ -8,60 +8,9 @@ repos:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: fmt
|
- id: nox
|
||||||
name: cargo fmt
|
name: nox
|
||||||
description: Format files with cargo fmt.
|
description: Run nox fixers and linters.
|
||||||
entry: cargo +nightly fmt
|
entry: nox -t fix style lint
|
||||||
language: system
|
language: system
|
||||||
types: [rust]
|
|
||||||
args: ["--"]
|
|
||||||
- id: cargo-check
|
|
||||||
name: cargo check
|
|
||||||
description: Check the package for errors.
|
|
||||||
entry: cargo check
|
|
||||||
language: system
|
|
||||||
args: ["--workspace"]
|
|
||||||
types: [rust]
|
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
- id: clippy
|
|
||||||
name: clippy
|
|
||||||
description: Lint rust sources
|
|
||||||
entry: cargo clippy
|
|
||||||
language: system
|
|
||||||
args: ["--workspace", "--", "-D", "warnings"]
|
|
||||||
types: [rust]
|
|
||||||
pass_filenames: false
|
|
||||||
- repo: https://github.com/psf/black
|
|
||||||
rev: 23.7.0
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
- repo: https://github.com/pycqa/isort
|
|
||||||
rev: 5.12.0
|
|
||||||
hooks:
|
|
||||||
- id: isort
|
|
||||||
name: isort (python)
|
|
||||||
- id: isort
|
|
||||||
name: isort (pyi)
|
|
||||||
types: [pyi]
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
||||||
# Ruff version.
|
|
||||||
rev: v0.0.287
|
|
||||||
hooks:
|
|
||||||
- id: ruff
|
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
|
||||||
types_or: [python, pyi]
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
||||||
rev: 'v1.5.1'
|
|
||||||
hooks:
|
|
||||||
- id: mypy
|
|
||||||
additional_dependencies:
|
|
||||||
- "typing-extensions>=4.0.0"
|
|
||||||
- repo: https://github.com/pycqa/flake8
|
|
||||||
rev: '6.1.0'
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
additional_dependencies:
|
|
||||||
- "Flake8-pyproject"
|
|
||||||
- "flake8-bugbear"
|
|
||||||
- "flake8-pyi"
|
|
||||||
args: ["--toml-config", "pyargus/pyproject.toml"]
|
|
||||||
|
|
|
||||||
58
noxfile.py
58
noxfile.py
|
|
@ -3,7 +3,6 @@ from pathlib import Path
|
||||||
import nox
|
import nox
|
||||||
|
|
||||||
nox.options.default_venv_backend = "mamba"
|
nox.options.default_venv_backend = "mamba"
|
||||||
nox.options.sessions = ["check"]
|
|
||||||
nox.options.reuse_existing_virtualenvs = True
|
nox.options.reuse_existing_virtualenvs = True
|
||||||
|
|
||||||
CURRENT_DIR = Path(__file__).parent.resolve()
|
CURRENT_DIR = Path(__file__).parent.resolve()
|
||||||
|
|
@ -21,10 +20,59 @@ def dev(session: nox.Session):
|
||||||
session.run("pre-commit", "install")
|
session.run("pre-commit", "install")
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session(tags=["style", "fix"], python=False)
|
||||||
def check(session: nox.Session):
|
def rustfmt(session: nox.Session):
|
||||||
session.conda_install("pre-commit")
|
if len(session.posargs) > 0:
|
||||||
session.run("pre-commit", "run", "-a")
|
session.run("cargo", "+nightly", "fmt", *session.posargs, external=True)
|
||||||
|
else:
|
||||||
|
session.run("cargo", "+nightly", "fmt", "--all", external=True)
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["lint", "fix"], python=False)
|
||||||
|
def cargo_check(session: nox.Session):
|
||||||
|
session.run("cargo", "check", "--workspace", external=True)
|
||||||
|
session.run("cargo", "clippy", "--workspace", external=True)
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["style", "fix"])
|
||||||
|
def black(session: nox.Session):
|
||||||
|
session.conda_install("black")
|
||||||
|
session.run("black", str(__file__))
|
||||||
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
|
session.run("black", ".")
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["style", "fix"])
|
||||||
|
def isort(session: nox.Session):
|
||||||
|
session.conda_install("isort")
|
||||||
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
|
session.run("isort", ".")
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["lint"])
|
||||||
|
def flake8(session: nox.Session):
|
||||||
|
session.conda_install(
|
||||||
|
"flake8",
|
||||||
|
"Flake8-pyproject",
|
||||||
|
"flake8-bugbear",
|
||||||
|
"flake8-pyi",
|
||||||
|
)
|
||||||
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
|
session.run("flake8")
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["lint", "fix"])
|
||||||
|
def ruff(session: nox.Session):
|
||||||
|
session.conda_install("ruff")
|
||||||
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
|
session.run("ruff", "--fix", "--exit-non-zero-on-fix", ".")
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(tags=["lint"])
|
||||||
|
def mypy(session: nox.Session):
|
||||||
|
session.conda_install("mypy", "typing-extensions", "pytest", "hypothesis")
|
||||||
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
|
session.run("mypy", ".")
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue