Skip to content

Commit

Permalink
chore: updates from learn-scientific-python
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Aug 2, 2024
1 parent b23c79f commit 2b04ffd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ updates:
interval: "monthly"
commit-message:
prefix: "chore"
include:
groups:
actions:
patterns:
- "*"
26 changes: 7 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,24 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

# Use bash by default in all jobs
defaults:
run:
shell: bash -el {0}

jobs:
# run pre-commit which includes many formatting and linting tools
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: pipx run nox -s pylint -- --output-format=github

# Run tests and upload to codecov
test:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
if: |
${{!startsWith(github.event.head_commit.message, 'docs:') }} ||
${{!startsWith(github.event.head_commit.message, 'style:') }}
needs: [pre-commit]
strategy:
# Otherwise, the workflow would stop if a single job fails. We want to
# run all of them to catch failures in different combinations.
Expand All @@ -55,7 +42,6 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
env:
FORCE_COLOR: 3
NUMBA_DISABLE_JIT: "1"
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -98,3 +84,5 @@ jobs:
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}


18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ exclude: |
)$
repos:
# - repo: https://github.com/psf/black-pre-commit-mirror
# rev: "23.9.1"
# hooks:
# - id: black-jupyter

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
Expand Down Expand Up @@ -110,3 +105,16 @@ repos:
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.18"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.29.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
33 changes: 12 additions & 21 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

DIR = Path(__file__).parent.resolve()

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "pylint", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"


@nox.session
Expand Down Expand Up @@ -71,41 +73,31 @@ def tests(session: nox.Session) -> None:
@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.
Build the docs. Pass --non-interactive to avoid serving. First positional
argument is the target directory.
"""

parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument(
"-b", dest="builder", default="html", help="Build target (default: html)"
)
parser.add_argument("output", nargs="?", help="Output directory")
args, posargs = parser.parse_known_args(session.posargs)
serve = args.builder == "html" and session.interactive

if args.builder != "html" and args.serve:
session.error("Must not specify non-HTML builder with --serve")

extra_installs = ["sphinx-autobuild"] if args.serve else []

session.install("-e.[docs]", *extra_installs)
session.chdir("docs")

if args.builder == "linkcheck":
session.run(
"sphinx-build", "-b", "linkcheck", ".", "_build/linkcheck", *posargs
)
return
session.install("-e.[docs]", "sphinx-autobuild")

shared_args = (
"-n", # nitpicky mode
"-T", # full tracebacks
f"-b={args.builder}",
".",
f"_build/{args.builder}",
"docs",
args.output or f"docs/_build/{args.builder}",
*posargs,
)

if args.serve:
session.run("sphinx-autobuild", *shared_args)
if serve:
session.run("sphinx-autobuild", "--open-browser", *shared_args)
else:
session.run("sphinx-build", "--keep-going", *shared_args)

Expand All @@ -117,11 +109,10 @@ def build_api_docs(session: nox.Session) -> None:
"""

session.install("sphinx")
session.chdir("docs")
session.run(
"sphinx-apidoc",
"-o",
"api/",
"docs/api/",
"--module-first",
"--no-toc",
"--force",
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ files = ["src"]
python_version = "3.9"
warn_unused_configs = true
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
disallow_untyped_defs = false
Expand Down Expand Up @@ -191,7 +190,7 @@ lint.select = [
"NPY", # NumPy specific rules
"PD", # pandas-vet
]
lint.extend-ignore = [
lint.ignore = [
"PLR", # Design related pylint codes
"G004", # Logging with f-strings
"PD901", # Bad variable name warning
Expand Down

0 comments on commit 2b04ffd

Please sign in to comment.