From 4beb98515353061c0549bfedc99e4b3f140ec390 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:47:45 -0400 Subject: [PATCH 01/18] chore(deps): bump versions (#389) * [create-pull-request] automated change * chore: update format Signed-off-by: Henry Schreiner * style: pre-commit fixes --------- Signed-off-by: Henry Schreiner Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> Co-authored-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- docs/pages/guides/packaging_compiled.md | 6 ++---- docs/pages/guides/style.md | 8 ++++---- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 6 +++--- ...['pybind11','skbuild','mesonpy'] %}main.cpp{% endif %} | 3 +-- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 133e0aee..cfcc359b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.0" + rev: "v0.3.2" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -43,7 +43,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.8.0" + rev: "v1.9.0" hooks: - id: mypy files: "(src|tests)" diff --git a/docs/pages/guides/packaging_compiled.md b/docs/pages/guides/packaging_compiled.md index fdb93876..3d76df57 100644 --- a/docs/pages/guides/packaging_compiled.md +++ b/docs/pages/guides/packaging_compiled.md @@ -225,8 +225,7 @@ PYBIND11_MODULE(_core, m) { Some other explanation about the add function. )pbdoc"); - m.def( - "subtract", [](int i, int j) { return i - j; }, R"pbdoc( + m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( Subtract two numbers Some other explanation about the subtract function. )pbdoc"); @@ -267,8 +266,7 @@ PYBIND11_MODULE(_core, m) { Some other explanation about the add function. )pbdoc"); - m.def( - "subtract", [](int i, int j) { return i - j; }, R"pbdoc( + m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( Subtract two numbers Some other explanation about the subtract function. )pbdoc"); diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 46756bbc..e64359e3 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.0" + rev: "v0.3.2" hooks: # id: ruff would go here if using both - id: ruff-format @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.0" + rev: "v0.3.2" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -535,7 +535,7 @@ The MyPy addition for pre-commit: ```yaml - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.8.0" + rev: "v1.9.0" hooks: - id: mypy files: src @@ -747,7 +747,7 @@ following pre-commit config: ```yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v17.0.6" + rev: "v18.1.0" hooks: - id: clang-format types_or: [c++, c, cuda] diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 4a4ea473..2540fb88 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.0" + rev: "v0.3.2" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -59,7 +59,7 @@ repos: {%- if cookiecutter.backend in ["pybind11", "skbuild", "mesonpy"] %} - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v17.0.6" + rev: "v18.1.0" hooks: - id: clang-format types_or: [c++, c, cuda] @@ -67,7 +67,7 @@ repos: {%- endif %} - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.8.0" + rev: "v1.9.0" hooks: - id: mypy files: src|tests diff --git a/{{cookiecutter.project_name}}/src/{% if cookiecutter.backend in ['pybind11','skbuild','mesonpy'] %}main.cpp{% endif %} b/{{cookiecutter.project_name}}/src/{% if cookiecutter.backend in ['pybind11','skbuild','mesonpy'] %}main.cpp{% endif %} index 2b8ed183..d570cd06 100644 --- a/{{cookiecutter.project_name}}/src/{% if cookiecutter.backend in ['pybind11','skbuild','mesonpy'] %}main.cpp{% endif %} +++ b/{{cookiecutter.project_name}}/src/{% if cookiecutter.backend in ['pybind11','skbuild','mesonpy'] %}main.cpp{% endif %} @@ -20,8 +20,7 @@ PYBIND11_MODULE(_core, m) { Some other explanation about the add function. )pbdoc"); - m.def( - "subtract", [](int i, int j) { return i - j; }, R"pbdoc( + m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( Subtract two numbers Some other explanation about the subtract function. )pbdoc"); From b8619e337f54c3b7071053726fc808a1adbcb1fe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:39:23 -0400 Subject: [PATCH 02/18] chore(deps): bump versions (#391) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- docs/pages/guides/gha_wheels.md | 2 +- docs/pages/guides/style.md | 10 +++++----- ...cookiecutter.__type=='compiled' %}cd.yml{% endif %} | 2 +- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfcc359b..dce6eb47 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/docs/pages/guides/gha_wheels.md b/docs/pages/guides/gha_wheels.md index ecf95c65..52409e6d 100644 --- a/docs/pages/guides/gha_wheels.md +++ b/docs/pages/guides/gha_wheels.md @@ -110,7 +110,7 @@ build_wheels: fetch-depth: 0 submodules: true - - uses: pypa/cibuildwheel@v2.16 + - uses: pypa/cibuildwheel@v2.17 - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index e64359e3..29a32cc5 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: # id: ruff would go here if using both - id: ruff-format @@ -141,7 +141,7 @@ Here is the snippet to add Black to your `.pre-commit-config.yml`: ```yaml - repo: https://github.com/psf/black-pre-commit-mirror - rev: "24.2.0" + rev: "24.3.0" hooks: - id: black ``` @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -747,7 +747,7 @@ following pre-commit config: ```yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.0" + rev: "v18.1.1" hooks: - id: clang-format types_or: [c++, c, cuda] @@ -764,7 +764,7 @@ If you have shell scripts, you can protect against common mistakes using ```yaml - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.9.0.6" + rev: "v0.10.0.1" hooks: - id: shellcheck ``` diff --git a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} index 5124675e..f12abcc0 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} +++ b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} @@ -43,7 +43,7 @@ jobs: with: fetch-depth: 0 - - uses: pypa/cibuildwheel@v2.16 + - uses: pypa/cibuildwheel@v2.17 - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 2540fb88..4a288261 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.2" + rev: "v0.3.3" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -59,7 +59,7 @@ repos: {%- if cookiecutter.backend in ["pybind11", "skbuild", "mesonpy"] %} - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.0" + rev: "v18.1.1" hooks: - id: clang-format types_or: [c++, c, cuda] @@ -81,7 +81,7 @@ repos: - id: codespell - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.9.0.6" + rev: "v0.10.0.1" hooks: - id: shellcheck From 172f7525b470435d77ed78179a74e9b86c399848 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:27:28 +0100 Subject: [PATCH 03/18] docs: fix typo (#392) --- src/sp_repo_review/checks/pyproject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sp_repo_review/checks/pyproject.py b/src/sp_repo_review/checks/pyproject.py index 2dc68d4b..d7496887 100644 --- a/src/sp_repo_review/checks/pyproject.py +++ b/src/sp_repo_review/checks/pyproject.py @@ -189,7 +189,7 @@ def check(pyproject: dict[str, Any]) -> bool: ```toml [tool.pytest.ini_options] - addops = ["-ra", "--strict-config", "--strict-markers"] + addopts = ["-ra", "--strict-config", "--strict-markers"] ``` """ options = pyproject["tool"]["pytest"]["ini_options"] @@ -210,7 +210,7 @@ def check(pyproject: dict[str, Any]) -> bool: ```toml [tool.pytest.ini_options] - addops = ["-ra", "--strict-config", "--strict-markers"] + addopts = ["-ra", "--strict-config", "--strict-markers"] ``` """ options = pyproject["tool"]["pytest"]["ini_options"] From e5f1fd7f167c9db2087365a400435771fcd398a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 04:17:03 -0400 Subject: [PATCH 04/18] chore(deps): bump versions (#393) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- docs/pages/guides/style.md | 8 ++++---- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dce6eb47..b061e7bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.3" + rev: "v0.3.4" hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 29a32cc5..684dd30a 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.3" + rev: "v0.3.4" hooks: # id: ruff would go here if using both - id: ruff-format @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.3" + rev: "v0.3.4" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -490,7 +490,7 @@ when clearly better (please always use them, they are faster) if you set ```yaml - repo: https://github.com/asottile/pyupgrade - rev: "v3.15.1" + rev: "v3.15.2" hooks: - id: pyupgrade args: ["--py38-plus"] @@ -747,7 +747,7 @@ following pre-commit config: ```yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.1" + rev: "v18.1.2" hooks: - id: clang-format types_or: [c++, c, cuda] diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 4a288261..81f84475 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.3" + rev: "v0.3.4" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -59,7 +59,7 @@ repos: {%- if cookiecutter.backend in ["pybind11", "skbuild", "mesonpy"] %} - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.1" + rev: "v18.1.2" hooks: - id: clang-format types_or: [c++, c, cuda] From 3b166e38f12b54e2a71cd85a83bea6546a399432 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 1 Apr 2024 00:30:23 -0400 Subject: [PATCH 05/18] ci: use uv, require recent nox (#394) * ci: try using a bit of uv Signed-off-by: Henry Schreiner * chore: use uv if available in noxfile Signed-off-by: Henry Schreiner * docs: add mentions of uv and pixi Signed-off-by: Henry Schreiner * Update docs/pages/tutorials/dev-environment.md --------- Signed-off-by: Henry Schreiner --- .github/workflows/reusable-cookie.yml | 64 +++++++++++++++--------- docs/pages/guides/gha_basic.md | 11 ++++ docs/pages/guides/tasks.md | 32 +++++++++++- docs/pages/tutorials/dev-environment.md | 20 ++++++++ noxfile.py | 3 +- {{cookiecutter.project_name}}/noxfile.py | 2 + 6 files changed, 107 insertions(+), 25 deletions(-) diff --git a/.github/workflows/reusable-cookie.yml b/.github/workflows/reusable-cookie.yml index d6c7a118..1a08e84a 100644 --- a/.github/workflows/reusable-cookie.yml +++ b/.github/workflows/reusable-cookie.yml @@ -37,8 +37,13 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true + - name: Setup uv + uses: yezz123/setup-uv@v4 + with: + uv-venv: ".venv" + - name: Install nox - run: pip install nox + run: uv pip install nox - name: Test setuptools run: nox -s 'tests(setuptools, novcs)' -s 'tests(setuptools, vcs)' @@ -97,55 +102,68 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + + - name: Setup uv + uses: yezz123/setup-uv@v4 + with: + uv-venv: ".venv" + + - name: Install nox + run: uv pip install nox + - name: Test setuptools run: | - pipx run nox -s 'nox(setuptools, vcs)' - pipx run nox -s 'nox(setuptools, vcs)' -- docs + nox -s 'nox(setuptools, vcs)' + nox -s 'nox(setuptools, vcs)' -- docs - name: Test pybind11 run: | - pipx run nox -s 'nox(pybind11, vcs)' - pipx run nox -s 'nox(pybind11, vcs)' -- docs + nox -s 'nox(pybind11, vcs)' + nox -s 'nox(pybind11, vcs)' -- docs - name: Test scikit-build run: | - pipx run nox -s 'nox(skbuild, vcs)' - pipx run nox -s 'nox(skbuild, vcs)' -- docs + nox -s 'nox(skbuild, vcs)' + nox -s 'nox(skbuild, vcs)' -- docs - name: Test poetry run: | - pipx run nox -s 'nox(poetry, novcs)' - pipx run nox -s 'nox(poetry, novcs)' -- docs + nox -s 'nox(poetry, novcs)' + nox -s 'nox(poetry, novcs)' -- docs - name: Test flit run: | - pipx run nox -s 'nox(flit, novcs)' - pipx run nox -s 'nox(flit, novcs)' -- docs + nox -s 'nox(flit, novcs)' + nox -s 'nox(flit, novcs)' -- docs - name: Test pdm run: | - pipx run nox -s 'nox(pdm, vcs)' - pipx run nox -s 'nox(pdm, vcs)' -- docs + nox -s 'nox(pdm, vcs)' + nox -s 'nox(pdm, vcs)' -- docs - name: Test whey run: | - pipx run nox -s 'nox(whey, novcs)' - pipx run nox -s 'nox(whey, novcs)' -- docs + nox -s 'nox(whey, novcs)' + nox -s 'nox(whey, novcs)' -- docs - name: Test maturin run: | - pipx run nox -s 'nox(maturin, novcs)' - pipx run nox -s 'nox(maturin, novcs)' -- docs + nox -s 'nox(maturin, novcs)' + nox -s 'nox(maturin, novcs)' -- docs - name: Test hatch run: | - pipx run nox -s 'nox(hatch, vcs)' - pipx run nox -s 'nox(hatch, vcs)' -- docs + nox -s 'nox(hatch, vcs)' + nox -s 'nox(hatch, vcs)' -- docs - name: Test setuptools PEP 621 run: | - pipx run nox -s 'nox(setuptools621, vcs)' - pipx run nox -s 'nox(setuptools621, vcs)' -- docs + nox -s 'nox(setuptools621, vcs)' + nox -s 'nox(setuptools621, vcs)' -- docs - name: Activate MSVC for Meson if: runner.os == 'Windows' @@ -153,8 +171,8 @@ jobs: - name: Test meson-python run: | - pipx run nox -s 'nox(mesonpy, novcs)' - pipx run nox -s 'nox(mesonpy, novcs)' -- docs + nox -s 'nox(mesonpy, novcs)' + nox -s 'nox(mesonpy, novcs)' -- docs dist: name: Distribution build diff --git a/docs/pages/guides/gha_basic.md b/docs/pages/guides/gha_basic.md index 68b31203..8544c0a0 100644 --- a/docs/pages/guides/gha_basic.md +++ b/docs/pages/guides/gha_basic.md @@ -261,12 +261,21 @@ And many other useful ones: built-in caching. - [conda-incubator/setup-miniconda](https://github.com/conda-incubator/setup-miniconda): Setup conda or mamba on GitHub Actions. +- [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi): Set up pixi + and install your environment(s). Try `cache: false` if saving/loading the + cache is slow. - [ruby/setup-ruby](https://github.com/ruby/setup-ruby): Setup Ruby if you need it for something. - [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request): Make a new PR with the current changes (more options than just using `gh`). You can even auto-merge PRs with `run: gh pr merge --merge --auto "1"` afterwards. +- [yezz123/setup-uv](https://github.com/yezz123/setup-uv): Set up `uv`. Has a + handy `uv-venv` option that will also set up and activate a virtual + environment for you. +- [gautamkrishnar/keepalive-workflow](https://github.com/gautamkrishnar/keepalive-workflow): + Keep GitHub actions alive for more than 60 days. Not usually needed if you've + set up the other suggestions here, like dependabot and pre-commit. A couple more from Python developers; note these do not provide `vX` moving tags like the official actions and most other actions, but instead have `release/vX` @@ -276,6 +285,8 @@ branches that you can use. Publish Python packages to PyPI. Supports trusted publisher deployment. - [re-actors/alls-green](https://github.com/re-actors/alls-green): Tooling to check to see if all jobs passed (supports allowed failures, too). +- [sigstore/gh-action-sigstore-python](https://github.com/sigstore/gh-action-sigstore-python): + Signing files in GitHub Actions with sigstore. There are also a few useful tools installed which can really simplify your workflow or adding custom actions. This includes system package managers (like diff --git a/docs/pages/guides/tasks.md b/docs/pages/guides/tasks.md index d6f43a4b..02ef4bda 100644 --- a/docs/pages/guides/tasks.md +++ b/docs/pages/guides/tasks.md @@ -80,7 +80,7 @@ action: You can now access all current versions of Python from nox. At least in GitHub Actions, you should add `--forcecolor` to your nox runs to get color output in -your logs, or set `env: FORCE_COLOR: 3`. If you'd like to customise the versions +your logs, or set `env: FORCE_COLOR: 3`. If you'd like to customize the versions of Python prepared for you, then use input like this: ```yaml @@ -314,6 +314,36 @@ def build(session: nox.Session) -> None: +(Removing the build directory is helpful for setuptools) + +### Faster with uv + +The [uv](https://github.com/astral-sh/uv) project is a Rust reimplementation of +pip, pip-tools, and venv that is very, very fast. You can tell nox to use `uv` +if it is on your system by adding the following to your `noxfile.py`: + +```python +nox.needs_version = ">=2024.3.2" +nox.options.default_venv_backend = "uv|virtualenv" +``` + +You can install `uv` with `pipx`, `brew`, etc. If you want to use uv in GitHub +Actions, one way is to use this: + +```yaml +- name: Setup uv + uses: yezz123/setup-uv@v4 +``` + +You do not need to set `with: uv-venv: ".venv"` for `nox` to be able to use +`uv`. + +Check your jobs with `uv`; most things do not need to change. The main +difference is `uv` doesn't install `pip` unless you ask it to. If you want to +interact with uv, nox might be getting uv from it's environment instead of the +system environment, so you can install `uv` if `shutil.which("uv")` returns +`None`. + ### Examples A standard diff --git a/docs/pages/tutorials/dev-environment.md b/docs/pages/tutorials/dev-environment.md index 905eb501..2265a387 100644 --- a/docs/pages/tutorials/dev-environment.md +++ b/docs/pages/tutorials/dev-environment.md @@ -87,6 +87,16 @@ leave the environment (or just close your shell). > If you like a different shell, like fish, there are several `activate` > scripts; the default one expects a bash-like shell. +{: .note-title } + +> Fast alternative +> +> You can also consider the [uv][] package, which is much, much faster version +> of pip and venv implemented in Rust. Just put `uv` in front of the commands +> you'd normally use; as long as you use venvs, it should be nearly the same. + +[uv]: https://github.com/astral-sh/uv + ### Option 2: Using conda You can also develop in conda. This is an especially good option if: @@ -113,6 +123,16 @@ conda activate env_name To deactivate, use `conda deactivate`, or leave your shell. +> Modern faster alternative +> +> You can also consider the [pixi][] package, which is much, much faster version +> of conda implemented in Rust. It has been completely redesigned to work around +> projects with a `pixi.toml` file instead of global environments. It's a new +> way to work (more similar to pdm/hatch/poetry from Python), but very powerful +> if you learn it. + +[pixi]: https://pixi.sh + ## Choosing an Editor Any plain text editor will serve our purposes for this guide. Bare bones editors diff --git a/noxfile.py b/noxfile.py index 7232fcfb..be943dde 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,8 +24,9 @@ import nox -nox.needs_version = ">=2022.1.7" +nox.needs_version = ">=2024.3.2" nox.options.sessions = ["rr_lint", "rr_tests", "rr_pylint", "readme"] +nox.options.default_venv_backend = "uv|virtualenv" DIR = Path(__file__).parent.resolve() with DIR.joinpath("cookiecutter.json").open() as f: diff --git a/{{cookiecutter.project_name}}/noxfile.py b/{{cookiecutter.project_name}}/noxfile.py index 337a63c6..1538cedc 100644 --- a/{{cookiecutter.project_name}}/noxfile.py +++ b/{{cookiecutter.project_name}}/noxfile.py @@ -13,7 +13,9 @@ {% endif -%} +nox.needs_version = ">=2024.3.2" nox.options.sessions = ["lint", "pylint", "tests"] +nox.options.default_venv_backend = "uv|virtualenv" @nox.session From a7343e9a69f5c349f73a6bc26e465b5610cc619c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 3 Apr 2024 09:52:21 -0400 Subject: [PATCH 06/18] fix(rr): pytest takes ints and floats (#398) Signed-off-by: Henry Schreiner --- src/sp_repo_review/checks/pyproject.py | 5 +- tests/test_checks.py | 95 ++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 tests/test_checks.py diff --git a/src/sp_repo_review/checks/pyproject.py b/src/sp_repo_review/checks/pyproject.py index d7496887..607ebec5 100644 --- a/src/sp_repo_review/checks/pyproject.py +++ b/src/sp_repo_review/checks/pyproject.py @@ -89,7 +89,10 @@ def check(pyproject: dict[str, Any]) -> bool: ``` """ options = pyproject["tool"]["pytest"]["ini_options"] - return "minversion" in options and int(options["minversion"].split(".")[0]) >= 6 + return ( + "minversion" in options + and int(str(options["minversion"]).split(".")[0]) >= 6 + ) class PP303(PyProject): diff --git a/tests/test_checks.py b/tests/test_checks.py new file mode 100644 index 00000000..a03c6cfb --- /dev/null +++ b/tests/test_checks.py @@ -0,0 +1,95 @@ +from sp_repo_review._compat import tomllib +from sp_repo_review.checks import pyproject + + +def test_PP002_okay(): + toml = tomllib.loads(""" + [build-system] + requires = ["setuptools"] + build-backend = "setuptools.build_meta" + """) + assert pyproject.PP002.check(toml) + + +def test_PP002_not_list(): + toml = tomllib.loads(""" + [build-system] + requires = "setuptools" + build-backend = "setuptools.build_meta" + """) + assert not pyproject.PP002.check(toml) + + +def test_PP002_missing(): + toml = tomllib.loads(""" + [project] + name = "hi" + version = "1.0.0" + """) + assert not pyproject.PP002.check(toml) + + +def test_PP003_no_wheel(): + toml = tomllib.loads(""" + [build-system] + requires = ["setuptools"] + build-backend = "setuptools.build_meta" + """) + assert pyproject.PP003.check(toml) + + +def test_PP003_has_wheel(): + toml = tomllib.loads(""" + [build-system] + requires = ["setuptools", "wheel"] + build-backend = "setuptools.build_meta" + """) + assert not pyproject.PP003.check(toml) + + +def test_PP302_okay_intstr(): + toml = tomllib.loads(""" + [tool.pytest.ini_options] + minversion = "7" + """) + assert pyproject.PP302.check(toml) + + +def test_PP302_okay_verstr(): + toml = tomllib.loads(""" + [tool.pytest.ini_options] + minversion = "7.0.2" + """) + assert pyproject.PP302.check(toml) + + +def test_PP302_okay_rawint(): + toml = tomllib.loads(""" + [tool.pytest.ini_options] + minversion = 7 + """) + assert pyproject.PP302.check(toml) + + +def test_PP302_okay_rawfloat(): + toml = tomllib.loads(""" + [tool.pytest.ini_options] + minversion = 7.0 + """) + assert pyproject.PP302.check(toml) + + +def test_PP302_missing(): + toml = tomllib.loads(""" + [tool.pytest] + ini_options = {} + """) + assert not pyproject.PP302.check(toml) + + +def test_PP302_too_low(): + toml = tomllib.loads(""" + [tool.pytest.ini_options] + minversion = "5" + """) + assert not pyproject.PP302.check(toml) From 45142bd07a93d73cbd339fc96701171ed57215c3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:24:08 -0400 Subject: [PATCH 07/18] chore: update pre-commit hooks (#397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update pre-commit hooks updates: - [github.com/astral-sh/ruff-pre-commit: v0.3.4 → v0.3.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.3.4...v0.3.5) - [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.1.0...v4.0.0-alpha.8) * Update .pre-commit-config.yaml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b061e7bc..efc2ced2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.4" + rev: "v0.3.5" hooks: - id: ruff args: ["--fix", "--show-fixes"] From 67d8a903961857daac3eedfedd9f94602843df67 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 3 Apr 2024 15:40:23 -0400 Subject: [PATCH 08/18] ci: copier pyyaml-include issue (#399) Signed-off-by: Henry Schreiner --- README.md | 2 +- noxfile.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca5bb47c..af1de00f 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Install `copier` and `copier-templates-extensions`. Using [pipx][], that's: ```bash pipx install copier -pipx inject copier copier-templates-extensions +pipx inject copier copier-templates-extensions 'pyyaml-include<2' ``` Now, run copier to generate your project: diff --git a/noxfile.py b/noxfile.py index be943dde..1d65de85 100644 --- a/noxfile.py +++ b/noxfile.py @@ -321,7 +321,9 @@ def nox_session(session: nox.Session, backend: str, vcs: bool) -> None: @nox.session() def compare_copier(session): - session.install("cookiecutter", "copier", "copier-templates-extensions") + session.install( + "cookiecutter", "copier", "copier-templates-extensions", "pyyaml-include<2" + ) tmp_dir = session.create_tmp() session.cd(tmp_dir) From d36b0590b4d4e0714d4c107c306f857b2908b01c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:51:32 -0400 Subject: [PATCH 09/18] chore(deps): bump versions (#395) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- docs/pages/guides/coverage.md | 2 +- docs/pages/guides/gha_basic.md | 2 +- docs/pages/guides/style.md | 2 +- {{cookiecutter.project_name}}/.github/workflows/ci.yml | 2 +- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/pages/guides/coverage.md b/docs/pages/guides/coverage.md index 21fc93e5..5e4896d6 100644 --- a/docs/pages/guides/coverage.md +++ b/docs/pages/guides/coverage.md @@ -91,7 +91,7 @@ enough for a simple testing suite, can be written as follows: ```yaml - name: Upload coverage report - uses: codecov/codecov-action@v4.1.0 + uses: codecov/codecov-action@v4.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} ``` diff --git a/docs/pages/guides/gha_basic.md b/docs/pages/guides/gha_basic.md index 8544c0a0..9eb62462 100644 --- a/docs/pages/guides/gha_basic.md +++ b/docs/pages/guides/gha_basic.md @@ -656,7 +656,7 @@ configure Pages. ```yaml - name: Setup Pages id: pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v5 ``` {% raw %} diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 684dd30a..a60b58f3 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -824,7 +824,7 @@ schemas, and you can load them via URL. It work on JSON, YAML, and TOML. ```yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.28.0" + rev: "0.28.1" hooks: - id: check-dependabot - id: check-github-workflows diff --git a/{{cookiecutter.project_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_name}}/.github/workflows/ci.yml index 344cc11c..2c7153ba 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/ci.yml @@ -74,6 +74,6 @@ jobs: --durations=20 - name: Upload coverage report - uses: codecov/codecov-action@v4.1.0 + uses: codecov/codecov-action@v4.1.1 with: token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 81f84475..353a74a5 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -118,7 +118,7 @@ repos: additional_dependencies: ["validate-pyproject-schema-store[all]"] - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.28.0" + rev: "0.28.1" hooks: {%- if cookiecutter.__ci == "github" %} - id: check-dependabot From d6b874f8f6af81ffba5a39838e2a05ff82b36c97 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 04:40:34 -0400 Subject: [PATCH 10/18] chore(deps): bump versions (#403) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- docs/pages/guides/coverage.md | 2 +- docs/pages/guides/style.md | 8 ++++---- {{cookiecutter.project_name}}/.github/workflows/ci.yml | 2 +- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index efc2ced2..c7d318af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ exclude: "^({{cookiecutter\\.project_name}}|hooks/pre_gen_project.py$)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.5.0" + rev: "v4.6.0" hooks: - id: check-added-large-files - id: check-case-conflict diff --git a/docs/pages/guides/coverage.md b/docs/pages/guides/coverage.md index 5e4896d6..38cc8235 100644 --- a/docs/pages/guides/coverage.md +++ b/docs/pages/guides/coverage.md @@ -91,7 +91,7 @@ enough for a simple testing suite, can be written as follows: ```yaml - name: Upload coverage report - uses: codecov/codecov-action@v4.1.1 + uses: codecov/codecov-action@v4.2.0 with: token: ${{ secrets.CODECOV_TOKEN }} ``` diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index a60b58f3..d1532311 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -31,7 +31,7 @@ options: ```yaml repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.5.0" + rev: "v4.6.0" hooks: - id: check-added-large-files - id: check-case-conflict @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.4" + rev: "v0.3.5" hooks: # id: ruff would go here if using both - id: ruff-format @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.4" + rev: "v0.3.5" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -747,7 +747,7 @@ following pre-commit config: ```yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.2" + rev: "v18.1.3" hooks: - id: clang-format types_or: [c++, c, cuda] diff --git a/{{cookiecutter.project_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_name}}/.github/workflows/ci.yml index 2c7153ba..14286bd1 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/ci.yml @@ -74,6 +74,6 @@ jobs: --durations=20 - name: Upload coverage report - uses: codecov/codecov-action@v4.1.1 + uses: codecov/codecov-action@v4.2.0 with: token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 353a74a5..3ec1170d 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.5.0" + rev: "v4.6.0" hooks: - id: check-added-large-files - id: check-case-conflict @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.4" + rev: "v0.3.5" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -59,7 +59,7 @@ repos: {%- if cookiecutter.backend in ["pybind11", "skbuild", "mesonpy"] %} - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.2" + rev: "v18.1.3" hooks: - id: clang-format types_or: [c++, c, cuda] From ac1ea0d1d0825efb2e8ae85058998a58e0524468 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 9 Apr 2024 04:44:25 -0400 Subject: [PATCH 11/18] Revert "ci: copier pyyaml-include issue" (#402) Revert "ci: copier pyyaml-include issue (#399)" This reverts commit 67d8a903961857daac3eedfedd9f94602843df67. --- README.md | 2 +- noxfile.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index af1de00f..ca5bb47c 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Install `copier` and `copier-templates-extensions`. Using [pipx][], that's: ```bash pipx install copier -pipx inject copier copier-templates-extensions 'pyyaml-include<2' +pipx inject copier copier-templates-extensions ``` Now, run copier to generate your project: diff --git a/noxfile.py b/noxfile.py index 1d65de85..be943dde 100644 --- a/noxfile.py +++ b/noxfile.py @@ -321,9 +321,7 @@ def nox_session(session: nox.Session, backend: str, vcs: bool) -> None: @nox.session() def compare_copier(session): - session.install( - "cookiecutter", "copier", "copier-templates-extensions", "pyyaml-include<2" - ) + session.install("cookiecutter", "copier", "copier-templates-extensions") tmp_dir = session.create_tmp() session.cd(tmp_dir) From cc2e43ad4c36f5d7a6b9838f0fa981074383fbee Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:30:03 +0200 Subject: [PATCH 12/18] docs: fix typo (#406) * docs: fix typo * docs: fix typo newly found by codespell --- docs/pages/guides/style.md | 2 +- src/sp_repo_review/checks/ruff.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index d1532311..10953c4b 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -582,7 +582,7 @@ command line. `strict = true` is now allowed in config files, too The extra strict options shown above, like `warn_unreachable` {% rr MY103 %}, and `ignore-without-code` {% rr MY104 %}, `redundant-expr` {% rr MY105 %}, and `truthy-bool` {% rr MY106 %} can trigger too often (like on `sys.platform` -checks) and have to be ignored occasionally, but can find some signifiant logic +checks) and have to be ignored occasionally, but can find some significant logic errors in your typing. [mypy page]: {% link pages/guides/mypy.md %} diff --git a/src/sp_repo_review/checks/ruff.py b/src/sp_repo_review/checks/ruff.py index b7ae9945..4353309c 100644 --- a/src/sp_repo_review/checks/ruff.py +++ b/src/sp_repo_review/checks/ruff.py @@ -75,7 +75,7 @@ def check(pyproject: dict[str, Any], ruff: dict[str, Any]) -> bool | str: match pyproject: case {"project": {"requires-python": str()}}: if "target-version" in ruff: - return "You have both Ruff's `target-version` and `project.requires-python`. You only need the later." + return "You have both Ruff's `target-version` and `project.requires-python`. You only need the latter." return True case _: return "target-version" in ruff From 3b6de6cb22c415172b2f34199f5ef9e152229267 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Thu, 18 Apr 2024 23:25:11 -0400 Subject: [PATCH 13/18] Explain `FORCE_COLOR: 3` (#410) * Explain FORCE_COLOR: 3 * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/reusable-cookie.yml | 2 ++ .github/workflows/reusable-rr-tests.yml | 2 ++ docs/pages/guides/tasks.md | 10 ++++++++-- {{cookiecutter.project_name}}/.github/workflows/ci.yml | 2 ++ ...cookiecutter.__type!='compiled' %}cd.yml{% endif %} | 2 ++ ...cookiecutter.__type=='compiled' %}cd.yml{% endif %} | 2 ++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-cookie.yml b/.github/workflows/reusable-cookie.yml index 1a08e84a..7d648a4c 100644 --- a/.github/workflows/reusable-cookie.yml +++ b/.github/workflows/reusable-cookie.yml @@ -4,6 +4,8 @@ on: workflow_call: 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 jobs: diff --git a/.github/workflows/reusable-rr-tests.yml b/.github/workflows/reusable-rr-tests.yml index 1153ffbb..39348039 100644 --- a/.github/workflows/reusable-rr-tests.yml +++ b/.github/workflows/reusable-rr-tests.yml @@ -4,6 +4,8 @@ on: workflow_call: 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 jobs: diff --git a/docs/pages/guides/tasks.md b/docs/pages/guides/tasks.md index 02ef4bda..c194deb9 100644 --- a/docs/pages/guides/tasks.md +++ b/docs/pages/guides/tasks.md @@ -80,8 +80,8 @@ action: You can now access all current versions of Python from nox. At least in GitHub Actions, you should add `--forcecolor` to your nox runs to get color output in -your logs, or set `env: FORCE_COLOR: 3`. If you'd like to customize the versions -of Python prepared for you, then use input like this: +your logs, or set `env: FORCE_COLOR: 3`[^force_color]. If you'd like to +customize the versions of Python prepared for you, then use input like this: ```yaml - uses: wntrblm/nox@2024.03.02 @@ -371,3 +371,9 @@ using nox include [pip](https://github.com/pypa/pip/blob/main/noxfile.py), [manylinux](https://github.com/pypa/manylinux/blob/main/noxfile.py), [packaging](https://github.com/pypa/packaging/blob/main/noxfile.py), and [packaging.python.org](https://github.com/pypa/packaging.python.org/blob/main/noxfile.py). + +[^force_color]: + Many color libraries just need `FORCE_COLOR` to be set to any value, but at + least [one](https://pypi.org/project/plumbum/) distinguishes color depth, + where "3" -> "256-bit color". For many use cases, using `FORCE_COLOR: 1` is + fine. diff --git a/{{cookiecutter.project_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_name}}/.github/workflows/ci.yml index 14286bd1..7f007658 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/ci.yml @@ -12,6 +12,8 @@ concurrency: 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 jobs: diff --git a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type!='compiled' %}cd.yml{% endif %} b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type!='compiled' %}cd.yml{% endif %} index 98d8d8b2..4538a63e 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type!='compiled' %}cd.yml{% endif %} +++ b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type!='compiled' %}cd.yml{% endif %} @@ -15,6 +15,8 @@ concurrency: 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 jobs: diff --git a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} index f12abcc0..1cf94c06 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} +++ b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %} @@ -11,6 +11,8 @@ concurrency: 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 jobs: From 371c6f4bcd05c041a70563d6e6da0680f6ec28e5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 18 Apr 2024 23:25:27 -0400 Subject: [PATCH 14/18] fix: correct logic for RF002 (#409) Signed-off-by: Henry Schreiner --- src/sp_repo_review/checks/ruff.py | 7 +++++-- tests/test_ruff.py | 33 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/test_ruff.py diff --git a/src/sp_repo_review/checks/ruff.py b/src/sp_repo_review/checks/ruff.py index 4353309c..2ec2d216 100644 --- a/src/sp_repo_review/checks/ruff.py +++ b/src/sp_repo_review/checks/ruff.py @@ -73,9 +73,12 @@ def check(pyproject: dict[str, Any], ruff: dict[str, Any]) -> bool | str: """ match pyproject: + case { + "project": {"requires-python": str()}, + "tool": {"ruff": {"target-version": object()}}, + }: + return "You have both Ruff's `target-version` and `project.requires-python`. You only need the latter." case {"project": {"requires-python": str()}}: - if "target-version" in ruff: - return "You have both Ruff's `target-version` and `project.requires-python`. You only need the latter." return True case _: return "target-version" in ruff diff --git a/tests/test_ruff.py b/tests/test_ruff.py new file mode 100644 index 00000000..f9beef90 --- /dev/null +++ b/tests/test_ruff.py @@ -0,0 +1,33 @@ +from sp_repo_review._compat import tomllib +from sp_repo_review.checks import ruff + + +def test_rf003_with_rp(): + toml = tomllib.loads(""" + project.requires-python = ">=3.12" + tool.ruff.anything = "1" + """) + assert ruff.RF002.check(toml, toml["tool"]["ruff"]) + + +def test_rf003_no_rp(): + toml = tomllib.loads(""" + project.name = "hi" + tool.ruff.target-version = "3.12" + """) + assert ruff.RF002.check(toml, toml["tool"]["ruff"]) + + +def test_rf003_both(): + toml = tomllib.loads(""" + project.requires-python = ">=3.12" + tool.ruff.target-version = "3.12" + """) + assert isinstance(ruff.RF002.check(toml, toml["tool"]["ruff"]), str) + + +def test_rf003_split_ok(): + toml = tomllib.loads(""" + project.requires-python = ">=3.12" + """) + assert ruff.RF002.check(toml, {"target-version": "3.12"}) From 6129bd279dd6f3cb39a16cc324507327493f54c9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:25:38 -0400 Subject: [PATCH 15/18] chore(deps): bump versions (#408) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- docs/pages/guides/coverage.md | 2 +- docs/pages/guides/style.md | 8 ++++---- docs/pages/guides/tasks.md | 4 ++-- {{cookiecutter.project_name}}/.github/workflows/ci.yml | 2 +- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7d318af..877a5f95 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.5" + rev: "v0.3.7" hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/docs/pages/guides/coverage.md b/docs/pages/guides/coverage.md index 38cc8235..4c87d547 100644 --- a/docs/pages/guides/coverage.md +++ b/docs/pages/guides/coverage.md @@ -91,7 +91,7 @@ enough for a simple testing suite, can be written as follows: ```yaml - name: Upload coverage report - uses: codecov/codecov-action@v4.2.0 + uses: codecov/codecov-action@v4.3.0 with: token: ${{ secrets.CODECOV_TOKEN }} ``` diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 10953c4b..59dbb454 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.5" + rev: "v0.3.7" hooks: # id: ruff would go here if using both - id: ruff-format @@ -141,7 +141,7 @@ Here is the snippet to add Black to your `.pre-commit-config.yml`: ```yaml - repo: https://github.com/psf/black-pre-commit-mirror - rev: "24.3.0" + rev: "24.4.0" hooks: - id: black ``` @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.5" + rev: "v0.3.7" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -824,7 +824,7 @@ schemas, and you can load them via URL. It work on JSON, YAML, and TOML. ```yaml - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.28.1" + rev: "0.28.2" hooks: - id: check-dependabot - id: check-github-workflows diff --git a/docs/pages/guides/tasks.md b/docs/pages/guides/tasks.md index c194deb9..8c2c8d90 100644 --- a/docs/pages/guides/tasks.md +++ b/docs/pages/guides/tasks.md @@ -75,7 +75,7 @@ On GitHub Actions or Azure, pipx is available by default, so you should use action: ```yaml -- uses: wntrblm/nox@2024.03.02 +- uses: wntrblm/nox@2024.04.15 ``` You can now access all current versions of Python from nox. At least in GitHub @@ -84,7 +84,7 @@ your logs, or set `env: FORCE_COLOR: 3`[^force_color]. If you'd like to customize the versions of Python prepared for you, then use input like this: ```yaml -- uses: wntrblm/nox@2024.03.02 +- uses: wntrblm/nox@2024.04.15 with: python-versions: "3.8, 3.9, 3.10, 3.11, 3.12, pypy-3.9, pypy-3.10" ``` diff --git a/{{cookiecutter.project_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_name}}/.github/workflows/ci.yml index 7f007658..6423c6eb 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/ci.yml @@ -76,6 +76,6 @@ jobs: --durations=20 - name: Upload coverage report - uses: codecov/codecov-action@v4.2.0 + uses: codecov/codecov-action@v4.3.0 with: token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 3ec1170d..951bbdf5 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.5" + rev: "v0.3.7" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -118,7 +118,7 @@ repos: additional_dependencies: ["validate-pyproject-schema-store[all]"] - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.28.1" + rev: "0.28.2" hooks: {%- if cookiecutter.__ci == "github" %} - id: check-dependabot From e0440e061a0275378208ac83ccf37e7485453328 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sun, 21 Apr 2024 01:56:14 -0400 Subject: [PATCH 16/18] chore: cleanups and bumps (#412) Signed-off-by: Henry Schreiner --- docs/_includes/interactive_repo_review.html | 2 +- pyproject.toml | 1 + tests/{test_checks.py => test_pyproject.py} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename tests/{test_checks.py => test_pyproject.py} (100%) diff --git a/docs/_includes/interactive_repo_review.html b/docs/_includes/interactive_repo_review.html index 041bf60e..f0ced0ba 100644 --- a/docs/_includes/interactive_repo_review.html +++ b/docs/_includes/interactive_repo_review.html @@ -22,7 +22,7 @@ deps={[ "repo-review~=0.10.0", "sp-repo-review==2024.03.10", - "validate-pyproject-schema-store==2024.03.11", + "validate-pyproject-schema-store==2024.04.20", "validate-pyproject[all]~=0.16.0", ]} />, diff --git a/pyproject.toml b/pyproject.toml index 27ac7fe9..ac0f2c6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ cli = [ ] test = [ "pytest >=7", + "repo-review >=0.10.5", ] dev = [ "pytest >=7", diff --git a/tests/test_checks.py b/tests/test_pyproject.py similarity index 100% rename from tests/test_checks.py rename to tests/test_pyproject.py From a168566f40b104c4f5c0337339a20ad4403c1fcb Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 22 Apr 2024 02:34:28 -0400 Subject: [PATCH 17/18] tests: use most recent repo-review in testing (#414) Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 2 +- pyproject.toml | 3 ++- tests/test_pyproject.py | 47 ++++++++++++++++++++--------------------- tests/test_ruff.py | 22 ++++++++++--------- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 877a5f95..89114f6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,7 +52,7 @@ repos: - click - markdown-it-py - pytest - - repo-review + - repo-review>=0.10.6 - rich - tomli - types-PyYAML diff --git a/pyproject.toml b/pyproject.toml index ac0f2c6e..0c34dc01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dynamic = ["version", "readme"] dependencies = [ "pyyaml", "repo-review", + "tomli; python_version<'3.11'", ] [project.optional-dependencies] @@ -40,7 +41,7 @@ cli = [ ] test = [ "pytest >=7", - "repo-review >=0.10.5", + "repo-review >=0.10.6", ] dev = [ "pytest >=7", diff --git a/tests/test_pyproject.py b/tests/test_pyproject.py index a03c6cfb..342e8e17 100644 --- a/tests/test_pyproject.py +++ b/tests/test_pyproject.py @@ -1,95 +1,94 @@ -from sp_repo_review._compat import tomllib -from sp_repo_review.checks import pyproject +from repo_review.testing import compute_check, toml_loads def test_PP002_okay(): - toml = tomllib.loads(""" + toml = toml_loads(""" [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" """) - assert pyproject.PP002.check(toml) + assert compute_check("PP002", pyproject=toml).result def test_PP002_not_list(): - toml = tomllib.loads(""" + toml = toml_loads(""" [build-system] requires = "setuptools" build-backend = "setuptools.build_meta" """) - assert not pyproject.PP002.check(toml) + assert not compute_check("PP002", pyproject=toml).result def test_PP002_missing(): - toml = tomllib.loads(""" + toml = toml_loads(""" [project] name = "hi" version = "1.0.0" """) - assert not pyproject.PP002.check(toml) + assert not compute_check("PP002", pyproject=toml).result def test_PP003_no_wheel(): - toml = tomllib.loads(""" + toml = toml_loads(""" [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" """) - assert pyproject.PP003.check(toml) + assert compute_check("PP003", pyproject=toml).result def test_PP003_has_wheel(): - toml = tomllib.loads(""" + toml = toml_loads(""" [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" """) - assert not pyproject.PP003.check(toml) + assert not compute_check("PP003", pyproject=toml).result def test_PP302_okay_intstr(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest.ini_options] minversion = "7" """) - assert pyproject.PP302.check(toml) + assert compute_check("PP302", pyproject=toml).result def test_PP302_okay_verstr(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest.ini_options] minversion = "7.0.2" """) - assert pyproject.PP302.check(toml) + assert compute_check("PP302", pyproject=toml).result def test_PP302_okay_rawint(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest.ini_options] minversion = 7 """) - assert pyproject.PP302.check(toml) + assert compute_check("PP302", pyproject=toml).result def test_PP302_okay_rawfloat(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest.ini_options] minversion = 7.0 """) - assert pyproject.PP302.check(toml) + assert compute_check("PP302", pyproject=toml).result def test_PP302_missing(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest] ini_options = {} """) - assert not pyproject.PP302.check(toml) + assert not compute_check("PP302", pyproject=toml).result def test_PP302_too_low(): - toml = tomllib.loads(""" + toml = toml_loads(""" [tool.pytest.ini_options] minversion = "5" """) - assert not pyproject.PP302.check(toml) + assert not compute_check("PP302", pyproject=toml).result diff --git a/tests/test_ruff.py b/tests/test_ruff.py index f9beef90..ccd39c8b 100644 --- a/tests/test_ruff.py +++ b/tests/test_ruff.py @@ -1,33 +1,35 @@ -from sp_repo_review._compat import tomllib -from sp_repo_review.checks import ruff +from repo_review.testing import compute_check, toml_loads def test_rf003_with_rp(): - toml = tomllib.loads(""" + toml = toml_loads(""" project.requires-python = ">=3.12" tool.ruff.anything = "1" """) - assert ruff.RF002.check(toml, toml["tool"]["ruff"]) + assert compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"]).result def test_rf003_no_rp(): - toml = tomllib.loads(""" + toml = toml_loads(""" project.name = "hi" tool.ruff.target-version = "3.12" """) - assert ruff.RF002.check(toml, toml["tool"]["ruff"]) + assert compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"]).result def test_rf003_both(): - toml = tomllib.loads(""" + toml = toml_loads(""" project.requires-python = ">=3.12" tool.ruff.target-version = "3.12" """) - assert isinstance(ruff.RF002.check(toml, toml["tool"]["ruff"]), str) + check_result = compute_check("RF002", pyproject=toml, ruff=toml["tool"]["ruff"]) + assert check_result.result is False def test_rf003_split_ok(): - toml = tomllib.loads(""" + toml = toml_loads(""" project.requires-python = ">=3.12" """) - assert ruff.RF002.check(toml, {"target-version": "3.12"}) + assert compute_check( + "RF002", pyproject=toml, ruff={"target-version": "3.12"} + ).result From 28d1a53da26f9daff6d9a49c50260421ad6d05e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 02:34:37 -0400 Subject: [PATCH 18/18] chore(deps): bump versions (#413) [create-pull-request] automated change Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- docs/pages/guides/style.md | 6 +++--- {{cookiecutter.project_name}}/.pre-commit-config.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89114f6d..0dd8d474 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.7" + rev: "v0.4.1" hooks: - id: ruff args: ["--fix", "--show-fixes"] diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 59dbb454..72110fbd 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -111,7 +111,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.7" + rev: "v0.4.1" hooks: # id: ruff would go here if using both - id: ruff-format @@ -201,7 +201,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.7" + rev: "v0.4.1" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -747,7 +747,7 @@ following pre-commit config: ```yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.3" + rev: "v18.1.4" hooks: - id: clang-format types_or: [c++, c, cuda] diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 951bbdf5..40bf3030 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.3.7" + rev: "v0.4.1" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -59,7 +59,7 @@ repos: {%- if cookiecutter.backend in ["pybind11", "skbuild", "mesonpy"] %} - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.3" + rev: "v18.1.4" hooks: - id: clang-format types_or: [c++, c, cuda]