Skip to content

Commit

Permalink
build(deps): support python3.11 (#356)
Browse files Browse the repository at this point in the history
build(deps): bump version from 0.3.4 to 0.4.0

ci(github): update CI actions files

refactor(ncdump): rewrite as a class for better style

style(format): include docs directory
  • Loading branch information
engeir authored Dec 7, 2023
1 parent 43b6889 commit 19a4aa6
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 671 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.0
nox==2022.11.21
nox==2023.4.22
nox-poetry==1.0.2
poetry==1.2.2
virtualenv==20.19.0
25 changes: 11 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@ jobs:
fail-fast: false
matrix:
include:
- { python-version: "3.7", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.7", os: ubuntu-latest, session: "tests" }
- { python-version: "3.8", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.8", os: ubuntu-latest, session: "tests" }
- { python-version: "3.9", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.9", os: ubuntu-latest, session: "tests" }
- { python-version: "3.10", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.10", os: ubuntu-latest, session: "tests" }
- { python-version: "3.10", os: macos-latest, session: "tests" }
- { python-version: "3.10", os: windows-latest, session: "tests" }
- { python-version: "3.10", os: ubuntu-latest, session: "docs-build" }
- { python-version: "3.10", os: ubuntu-latest, session: "pre-commit" }
# - { python-version: "3.10", os: ubuntu-latest, session: "safety" }
- { python-version: "3.10", os: ubuntu-latest, session: "typeguard" }
- { python-version: "3.10", os: ubuntu-latest, session: "xdoctest" }
- { python-version: "3.11", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.11", os: ubuntu-latest, session: "tests" }
- { python-version: "3.11", os: macos-latest, session: "tests" }
- { python-version: "3.11", os: windows-latest, session: "tests" }
- { python-version: "3.11", os: ubuntu-latest, session: "docs-build" }
- { python-version: "3.11", os: ubuntu-latest, session: "pre-commit" }
- { python-version: "3.11", os: ubuntu-latest, session: "typeguard" }
- { python-version: "3.11", os: ubuntu-latest, session: "xdoctest" }

env:
NOXSESSION: ${{ matrix.session }}
Expand Down Expand Up @@ -105,10 +102,10 @@ jobs:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Upgrade pip
run: |
Expand All @@ -126,6 +123,6 @@ jobs:
nox --version
- name: Run codecov session
run: nox --sessions tests-3.10 coverage
run: nox --sessions tests-3.11 coverage
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
76 changes: 58 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,90 @@
repos:
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
require_serial: true
- id: check-added-large-files
name: Check for added large files
stages: [commit]
entry: check-added-large-files
language: system

- id: ruff_format
name: ruff_format
stages: [commit]
language: system
entry: poetry run ruff format src tests docs
types: [python]

- id: ruff
name: ruff
stages: [commit]
language: system
entry: poetry run ruff --fix src tests docs
types: [python]

- id: xdoctest
name: xdoctest
stages: [commit]
language: system
entry: poetry run xdoctest
types: [python]

- id: pydocstringformatter
name: pydocstringformatter
stages: [commit]
language: system
entry: poetry run pydocstringformatter src tests docs
types: [python]

- id: mypy
name: mypy
stages: [commit]
language: system
entry: poetry run mypy
types: [python]
require_serial: true

- id: pydoclint
name: pydoclint
stages: [commit]
language: system
entry: poetry run pydoclint src tests docs
types: [python]
require_serial: true

- id: pytest
name: pytest
stages: [commit]
language: system
entry: poetry run pytest tests
types: [python]
pass_filenames: false

- id: check-toml
name: Check Toml
entry: check-toml
language: system
types: [toml]

- id: check-yaml
name: Check Yaml
entry: check-yaml
language: system
types: [yaml]

- id: end-of-file-fixer
name: Fix End of Files
entry: end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
require_serial: true
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=src]

- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .rtx.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tools]
python = {version='3.10', virtualenv='.venv'}
python = { version = "3.11", virtualenv = ".venv" }
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Sphinx configuration."""
from datetime import datetime


project = "Rich NcDump"
author = "Eirik Enger"
copyright = f"{datetime.now().year}, {author}"
Expand Down
60 changes: 25 additions & 35 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@


package = "ncdump_rich"
python_versions = ["3.11", "3.10", "3.9", "3.8", "3.7"]
nox.needs_version = ">= 2021.6.6"
python_versions = ["3.11", "3.10", "3.9"]
nox.needs_version = ">= 2023.4.22"
nox.options.sessions = (
"pre-commit",
# "safety",
"mypy",
"black",
"ruff",
"tests",
"typeguard",
"xdoctest",
Expand All @@ -46,11 +45,11 @@ def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> Non
Parameters
----------
session: Session
session : Session
The Session object.
args: str
*args : str
Command-line arguments for pip.
kwargs: Any
**kwargs : Any
Additional keyword arguments for Session.install.
"""
with tempfile.NamedTemporaryFile() as requirements:
Expand All @@ -77,10 +76,11 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
Parameters
----------
session: The Session object.
session : Session
The Session object.
"""
if session.bin is None:
return
# if session.bin is None:
# return

virtualenv = session.env.get("VIRTUAL_ENV")
if virtualenv is None:
Expand Down Expand Up @@ -120,36 +120,26 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
hook.write_text("\n".join(lines))


@session(name="pre-commit", python="3.10")
@session(name="pre-commit", python="3.11")
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
session.install(
"black",
"darglint",
"flake8",
"flake8-bandit",
"flake8-bugbear",
"flake8-docstrings",
"flake8-rst-docstrings",
"pep8-naming",
"ruff",
"pydoclint",
"mypy",
"pytest",
"pydocstringformatter",
"pre-commit",
"pre-commit-hooks",
"reorder-python-imports",
"xdoctest",
)
session.install(".")
session.run("pre-commit", *args)
if args and args[0] == "install":
activate_virtualenv_in_precommit_hooks(session)


# @session(python="3.10")
# def safety(session: Session) -> None:
# """Scan dependencies for insecure packages."""
# requirements = session.poetry.export_requirements()
# session.install("safety")
# session.run("safety", "check", "--full-report", f"--file={requirements}")


@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
Expand All @@ -162,11 +152,11 @@ def mypy(session: Session) -> None:


@session(python=python_versions)
def black(session: Session) -> None:
"""Format using black."""
def ruff(session: Session) -> None:
"""Format using ruff."""
args = session.posargs or ["src", "tests", "docs/conf.py"]
session.install("black")
session.run("black", *args)
session.install("ruff")
session.run("ruff", *args)


@session(python=python_versions)
Expand All @@ -181,7 +171,7 @@ def tests(session: Session) -> None:
session.notify("coverage", posargs=[])


@session(python="3.10")
@session(python="3.11")
def coverage(session: Session) -> None:
"""Produce the coverage report."""
install_with_constraints(session, "coverage[toml]", "codecov")
Expand All @@ -208,7 +198,7 @@ def xdoctest(session: Session) -> None:
session.run("python", "-m", "xdoctest", package, *args)


@session(name="docs-build", python="3.10")
@session(name="docs-build", python="3.11")
def docs_build(session: Session) -> None:
"""Build the documentation."""
args = session.posargs or ["docs", "docs/_build"]
Expand All @@ -222,7 +212,7 @@ def docs_build(session: Session) -> None:
session.run("sphinx-build", *args)


@session(python="3.10")
@session(python="3.11")
def docs(session: Session) -> None:
"""Build and serve the documentation with live reloading on file changes."""
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
Expand Down
Loading

0 comments on commit 19a4aa6

Please sign in to comment.