From db25a54d2df19dc22fd8683e1e061d73f44664e8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 20:31:46 +0000 Subject: [PATCH 01/14] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0) - [github.com/asottile/pyupgrade: v3.2.2 → v3.3.1](https://github.com/asottile/pyupgrade/compare/v3.2.2...v3.3.1) - [github.com/psf/black: 22.10.0 → 22.12.0](https://github.com/psf/black/compare/22.10.0...22.12.0) - [github.com/PyCQA/docformatter: v1.5.0 → v1.5.1](https://github.com/PyCQA/docformatter/compare/v1.5.0...v1.5.1) - [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0) - [github.com/dosisod/refurb: v1.5.0 → v1.9.1](https://github.com/dosisod/refurb/compare/v1.5.0...v1.9.1) - [github.com/codespell-project/codespell: v2.1.0 → v2.2.2](https://github.com/codespell-project/codespell/compare/v2.1.0...v2.2.2) - [github.com/pre-commit/mirrors-mypy: v0.990 → v0.991](https://github.com/pre-commit/mirrors-mypy/compare/v0.990...v0.991) --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00fa12e..adce3fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ exclude: | repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -35,7 +35,7 @@ repos: - id: python-use-type-annotations - id: text-unicode-replacement-char - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] @@ -52,16 +52,16 @@ repos: {{cookiecutter.project_slug}}/setup.cfg )$ - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 + rev: v1.5.1 hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [ @@ -81,7 +81,7 @@ repos: Pygments, ] - repo: https://github.com/dosisod/refurb - rev: v1.5.0 + rev: v1.9.1 hooks: - id: refurb args: [--ignore, FURB126] @@ -105,7 +105,7 @@ repos: ] pass_filenames: false - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.2 hooks: - id: codespell - repo: https://github.com/executablebooks/mdformat @@ -147,7 +147,7 @@ repos: - id: tryceratops exclude: "{{cookiecutter.project_slug}}/pyproject.toml" - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v0.990' + rev: 'v0.991' hooks: - id: mypy args: [ From da34063337183982232764288e8f6b0063fdf651 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 1 Jan 2023 18:33:04 +0100 Subject: [PATCH 02/14] Fix ruff. --- .pre-commit-config.yaml | 34 ++++++---------------------------- README.md | 2 +- pyproject.toml | 40 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adce3fd..039a26a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,36 +60,18 @@ repos: hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.205 hooks: - - id: flake8 - additional_dependencies: [ - flake8-alfred, - flake8-bugbear, - flake8-builtins, - flake8-comprehensions, - flake8-docstrings, - flake8-eradicate, - flake8-print, - flake8-pytest-style, - flake8-todo, - flake8-typing-imports, - flake8-unused-arguments, - pep8-naming, - pydocstyle, - Pygments, - ] + - id: ruff + args: [hooks, tests] + pass_filenames: false - repo: https://github.com/dosisod/refurb rev: v1.9.1 hooks: - id: refurb args: [--ignore, FURB126] exclude: ({{cookiecutter.project_slug}}) -- repo: https://github.com/guilatrova/tryceratops - rev: v1.1.0 - hooks: - - id: tryceratops - repo: https://github.com/econchick/interrogate rev: 1.5.0 hooks: @@ -141,11 +123,7 @@ repos: rev: v2.2.2 hooks: - id: codespell -- repo: https://github.com/guilatrova/tryceratops - rev: v1.1.0 - hooks: - - id: tryceratops - exclude: "{{cookiecutter.project_slug}}/pyproject.toml" + additional_dependencies: [tomli] - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.991' hooks: diff --git a/README.md b/README.md index fe92c2e..2143705 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![MIT license](https://img.shields.io/github/license/pytask-dev/cookiecutter-pytask-project)](https://github.com/pytask-dev/cookiecutter-pytask-project) [![image](https://readthedocs.org/projects/cookiecutter-pytask-project/badge/?version=latest)](https://cookiecutter-pytask-project.readthedocs.io/en/latest) -[![image](https://img.shields.io/github/workflow/status/pytask-dev/cookiecutter-pytask-project/main/main)](https://github.com/pytask-dev/cookiecutter-pytask-project/actions?query=branch%3Amain) +[![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/cookiecutter-pytask-project/main.yml?branch=main)](https://github.com/pytask-dev/cookiecutter-pytask-project/actions?query=branch%3Amain) [![image](https://codecov.io/gh/pytask-dev/cookiecutter-pytask-project/branch/main/graph/badge.svg)](https://codecov.io/gh/pytask-dev/cookiecutter-pytask-project) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/cookiecutter-pytask-project/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/cookiecutter-pytask-project/main) [![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/pyproject.toml b/pyproject.toml index cadab6b..55496ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,12 @@ [build-system] requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] +build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "version.py" -[tool.tryceratops] -ignore = ["TC003"] - - [tool.mypy] files = ["hooks", "tests"] exclude = "{{cookiecutter.project_slug}}" @@ -26,3 +23,38 @@ warn_unused_ignores = true module = "tests.*" disallow_untyped_defs = false ignore_errors = true + + +[tool.ruff] +target-version = "py37" +select = ["ALL"] +fix = true +extend-ignore = [ + # Numpy docstyle + "D107", + "D203", + "D212", + "D213", + "D402", + "D404", + "D413", + "D415", + "D416", + "D417", + # Others. + "RET504", # unnecessary variable assignment before return. + "S101", # raise errors for asserts. + "B905", # strict parameter for zip that was implemented in py310. + "I", # ignore isort + "ANN101", # type annotating self + "ANN102", # type annotating cls + "FBT", # flake8-boolean-trap + "EM", # flake8-errmsg + "ANN401", # flake8-annotate typing.Any + "PD", # pandas-vet + "UP", # pyupgrade is too aggressive for py<3.10 +] + + +[tool.ruff.per-file-ignores] +"tests/*" = ["D", "ANN"] From 111aa31fce3b6124b537f3cd0460d4da1496da22 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 1 Jan 2023 18:55:03 +0100 Subject: [PATCH 03/14] Fix hooks. --- .pre-commit-config.yaml | 9 ---- cookiecutter.json | 2 +- pyproject.toml | 7 ++- .../.pre-commit-config.yaml | 53 ++++++------------- {{cookiecutter.project_slug}}/pyproject.toml | 38 +++++++++++++ 5 files changed, 61 insertions(+), 48 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 039a26a..48a94b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,11 +34,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: [--py37-plus] - repo: https://github.com/asottile/reorder_python_imports rev: v3.9.0 hooks: @@ -86,10 +81,6 @@ repos: "{{cookiecutter.project_slug}}/tests/test_import.py" ] pass_filenames: false -- repo: https://github.com/codespell-project/codespell - rev: v2.2.2 - hooks: - - id: codespell - repo: https://github.com/executablebooks/mdformat rev: 0.7.16 hooks: diff --git a/cookiecutter.json b/cookiecutter.json index 331cfb7..6b7ff0a 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,7 +6,7 @@ "project_description": "A project for ...", "github_username": "{{ cookiecutter.author.lower().replace(' ', '') }}", "github_email": "{{ cookiecutter.email }}", - "python_version": "3.8", + "python_version": "3.10", "add_tox": ["yes", "no"], "add_github_actions": ["yes", "no"], "add_mypy": ["yes", "no"], diff --git a/pyproject.toml b/pyproject.toml index 55496ec..82bc87f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,12 +36,12 @@ extend-ignore = [ "D212", "D213", "D402", - "D404", "D413", "D415", "D416", "D417", # Others. + "D404", # Do not start module docstring with "This". "RET504", # unnecessary variable assignment before return. "S101", # raise errors for asserts. "B905", # strict parameter for zip that was implemented in py310. @@ -52,9 +52,12 @@ extend-ignore = [ "EM", # flake8-errmsg "ANN401", # flake8-annotate typing.Any "PD", # pandas-vet - "UP", # pyupgrade is too aggressive for py<3.10 ] [tool.ruff.per-file-ignores] "tests/*" = ["D", "ANN"] + + +[tool.ruff.pydocstyle] +convention = "numpy" diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 17f5274..f05aa76 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=25'] @@ -25,7 +25,7 @@ repos: - id: python-use-type-annotations - id: text-unicode-replacement-char - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] @@ -39,54 +39,31 @@ repos: hooks: - id: setup-cfg-fmt - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 + rev: v1.5.1 hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] -- repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 +{% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.205 hooks: - - id: flake8 - additional_dependencies: [ - flake8-alfred, - flake8-bugbear, - flake8-builtins, - flake8-comprehensions, - flake8-docstrings, - flake8-eradicate, - flake8-print, - flake8-pytest-style, - flake8-todo, - flake8-typing-imports, - flake8-unused-arguments, - pep8-naming, - pydocstyle, - Pygments, - ] -{% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/dosisod/refurb - rev: v1.5.0 + - id: ruff +- repo: https://github.com/dosisod/refurb + rev: v1.9.1 hooks: - id: refurb args: [--ignore, FURB126] -{% endif %}- repo: https://github.com/guilatrova/tryceratops - rev: v1.1.0 - hooks: - - id: tryceratops +{% endif %} - repo: https://github.com/econchick/interrogate rev: 1.5.0 hooks: - id: interrogate args: [-v, --fail-under=40] -- repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell - repo: https://github.com/executablebooks/mdformat - rev: 0.7.14 + rev: 0.7.16 hooks: - id: mdformat additional_dependencies: [ @@ -111,7 +88,7 @@ repos: # path/to/file.py # )$ {% if cookiecutter.add_mypy == "yes" %}- repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v0.990' + rev: 'v0.991' hooks: - id: mypy args: [ @@ -119,7 +96,11 @@ repos: --ignore-missing-imports, ] pass_filenames: false -{% endif %}- repo: meta +{% endif %}- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell +- repo: meta hooks: - id: check-hooks-apply - id: check-useless-excludes diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index e322336..9d0de2a 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -26,3 +26,41 @@ ignore_errors = true [tool.pytask.ini_options] paths = "./src/{{ cookiecutter.project_slug }}" + + +[tool.ruff] +target-version = "py{{ cookiecutter.python_version | replace('.', '') }}" +select = ["ALL"] +fix = true +extend-ignore = [ + # Numpy docstyle + "D107", + "D203", + "D212", + "D213", + "D402", + "D413", + "D415", + "D416", + "D417", + # Others. + "D404", # Do not start module docstring with "This". + "RET504", # unnecessary variable assignment before return. + "S101", # raise errors for asserts. + "B905", # strict parameter for zip that was implemented in py310. + "I", # ignore isort + "ANN101", # type annotating self + "ANN102", # type annotating cls + "FBT", # flake8-boolean-trap + "EM", # flake8-errmsg + "ANN401", # flake8-annotate typing.Any + "PD", # pandas-vet +] + + +[tool.ruff.per-file-ignores] +"tests/*" = ["D", "ANN"] + + +[tool.ruff.pydocstyle] +convention = "numpy" From 2ef947f5f502f31bcc630d739938095e9ab86e7e Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 1 Jan 2023 19:02:49 +0100 Subject: [PATCH 04/14] Remove flake8 config. --- tox.ini | 12 ------------ {{cookiecutter.project_slug}}/tox.ini | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/tox.ini b/tox.ini index d521a42..470470c 100644 --- a/tox.ini +++ b/tox.ini @@ -32,18 +32,6 @@ commands = sphinx-build -T -b html -d {envtmpdir}/doctrees . {envtmpdir}/html - sphinx-build -T -b linkcheck -d {envtmpdir}/doctrees . {envtmpdir}/linkcheck -[flake8] -docstring-convention = numpy -ignore = - D ; ignore missing docstrings. - E203 ; ignore whitespace around : which is enforced by Black. - W503 ; ignore linebreak before binary operator which is enforced by Black. - PT006 ; ignore that parametrizing tests with tuple argument names is preferred. -max-line-length = 88 -pytest-mark-no-parentheses = true -warn-symbols = - pytest.mark.wip = Remove 'wip' mark for tests. - [pytest] addopts = --doctest-modules testpaths = diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index d32b57c..a39f6d0 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -21,18 +21,6 @@ conda_deps = commands = pytest {posargs} -[flake8] -docstring-convention = numpy -ignore = - D ; ignore missing docstrings. - E203 ; ignore whitespace around : which is enforced by Black. - W503 ; ignore linebreak before binary operator which is enforced by Black. - PT006 ; ignore that parametrizing tests with tuple argument names is preferred. -max-line-length = 88 -pytest-mark-no-parentheses = true -warn-symbols = - pytest.mark.wip = Remove 'wip' mark for tests. - [pytest] addopts = --doctest-modules filterwarnings = From 222e5b83828e415f152e7fad5686000a30e548e4 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 1 Jan 2023 19:06:50 +0100 Subject: [PATCH 05/14] to changes. --- docs/source/changes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/source/changes.md b/docs/source/changes.md index b5f3cc3..745699c 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -3,6 +3,10 @@ This is a record of all past cookiecutter-pytask-project releases and what went into them in reverse chronological order. +## 1.4.0 - 2023-xx-xx + +- {pull}`29` adds ruff and refurb to pre-commits and fixes CI banner. + ## 1.3.0 - 2022-11-20 - {pull}`22` removes sphinx-click and renames docs environment to From 7819ed948d1d1b186a225ba655213627d29970f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 21:10:37 +0000 Subject: [PATCH 06/14] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pygrep-hooks: v1.9.0 → v1.10.0](https://github.com/pre-commit/pygrep-hooks/compare/v1.9.0...v1.10.0) - [github.com/PyCQA/docformatter: v1.5.1 → v1.6.0.rc1](https://github.com/PyCQA/docformatter/compare/v1.5.1...v1.6.0.rc1) - [github.com/charliermarsh/ruff-pre-commit: v0.0.205 → v0.0.237](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.205...v0.0.237) - [github.com/dosisod/refurb: v1.9.1 → v1.10.0](https://github.com/dosisod/refurb/compare/v1.9.1...v1.10.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 48a94b2..0e41670 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods @@ -51,18 +51,18 @@ repos: hooks: - id: black - repo: https://github.com/PyCQA/docformatter - rev: v1.5.1 + rev: v1.6.0.rc1 hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.205 + rev: v0.0.237 hooks: - id: ruff args: [hooks, tests] pass_filenames: false - repo: https://github.com/dosisod/refurb - rev: v1.9.1 + rev: v1.10.0 hooks: - id: refurb args: [--ignore, FURB126] From 6cfae732584343902a90f89d6909716a8b8be630 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 21:11:03 +0000 Subject: [PATCH 07/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- hooks/post_gen_project.py | 4 ++-- hooks/pre_gen_project.py | 6 +++--- tests/test_cookie.py | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index c8c4955..6bc24ec 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -39,7 +39,7 @@ def main() -> None: remove_file(project_path, ".readthedocs.yaml") subprocess.run( - ("git", "init", "--initial-branch", "main"), check=True, capture_output=True + ("git", "init", "--initial-branch", "main"), check=True, capture_output=True, ) if "{{ cookiecutter.make_initial_commit }}" == "yes": @@ -82,7 +82,7 @@ def main() -> None: else: warnings.warn( "conda environment could not be created since no conda or mamba " - "executable was found." + "executable was found.", ) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index f46714f..80cadc6 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -36,7 +36,7 @@ def main() -> None: if not re.match(ENVIRON_REGEX, environment_name): raise ValueError( - EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name) + EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name), ) python_version = "{{ cookiecutter.python_version }}" @@ -44,8 +44,8 @@ def main() -> None: if not re.match(PYTHONVERSION_REGEX, python_version): raise ValueError( EXCEPTION_MSG_PYTHONVERSION.format( - min_python_version=PYTHONVERSION_MIN, python_version=python_version - ) + min_python_version=PYTHONVERSION_MIN, python_version=python_version, + ), ) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index d8cb6fc..b93b669 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -8,10 +8,10 @@ _PYTHON_VERSION = ".".join(map(str, sys.version_info[:2])) -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_bake_project(cookies): result = cookies.bake( - extra_context={"project_slug": "helloworld", "python_version": _PYTHON_VERSION} + extra_context={"project_slug": "helloworld", "python_version": _PYTHON_VERSION}, ) assert result.exit_code == 0 @@ -20,13 +20,13 @@ def test_bake_project(cookies): assert result.project_path.is_dir() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_readthedocs(cookies): result = cookies.bake( extra_context={ "add_readthedocs": "no", "python_version": ".".join(map(str, sys.version_info[:2])), - } + }, ) rtd_config = result.project_path.joinpath(".readthedocs.yaml") @@ -39,10 +39,10 @@ def test_remove_readthedocs(cookies): assert "readthedocs" not in readme -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_github_actions(cookies): result = cookies.bake( - extra_context={"add_github_actions": "no", "python_version": _PYTHON_VERSION} + extra_context={"add_github_actions": "no", "python_version": _PYTHON_VERSION}, ) ga_config = result.project_path.joinpath(".github", "workflows", "main.yml") @@ -55,10 +55,10 @@ def test_remove_github_actions(cookies): assert "github/workflow/status" not in readme -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_tox(cookies): result = cookies.bake( - extra_context={"add_tox": "no", "python_version": _PYTHON_VERSION} + extra_context={"add_tox": "no", "python_version": _PYTHON_VERSION}, ) ga_config = result.project_path.joinpath(".github", "workflows", "main.yml") @@ -71,13 +71,13 @@ def test_remove_tox(cookies): assert not tox.exists() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_license(cookies): result = cookies.bake( extra_context={ "open_source_license": "Not open source", "python_version": _PYTHON_VERSION, - } + }, ) license_ = result.project_path.joinpath("LICENSE") @@ -88,7 +88,7 @@ def test_remove_license(cookies): assert not license_.exists() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() @pytest.mark.skipif(os.environ.get("CI") is None, reason="Run only in CI.") def test_check_conda_environment_creation_and_run_all_checks(cookies): """Test that the conda environment is created and pre-commit passes.""" @@ -98,7 +98,7 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): "make_initial_commit": "yes", "create_conda_environment_at_finish": "yes", "python_version": _PYTHON_VERSION, - } + }, ) assert result.exit_code == 0 @@ -108,7 +108,7 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): # Switch branch before pre-commit because otherwise failure because on main # branch. subprocess.run( - ("git", "checkout", "-b", "test"), cwd=result.project_path, check=True + ("git", "checkout", "-b", "test"), cwd=result.project_path, check=True, ) # Check linting, but not on the first try since formatters fix stuff. From b6d6f6b57f9128d2a9bd7710508cd0419e239608 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 20:41:17 +0100 Subject: [PATCH 08/14] Set clean. --- .pre-commit-config.yaml | 5 ----- pyproject.toml | 1 + {{cookiecutter.project_slug}}/pyproject.toml | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 48a94b2..7e9f8a0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,11 +50,6 @@ repos: rev: 22.12.0 hooks: - id: black -- repo: https://github.com/PyCQA/docformatter - rev: v1.5.1 - hooks: - - id: docformatter - args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.205 hooks: diff --git a/pyproject.toml b/pyproject.toml index 82bc87f..40511c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ extend-ignore = [ "EM", # flake8-errmsg "ANN401", # flake8-annotate typing.Any "PD", # pandas-vet + "COM812", # trailing comma missing, but black takes care of that ] diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 9d0de2a..5365997 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -55,6 +55,7 @@ extend-ignore = [ "EM", # flake8-errmsg "ANN401", # flake8-annotate typing.Any "PD", # pandas-vet + "COM812", # trailing comma missing, but black takes care of that ] From 604c8b6ac2f1e07d6d83678b6045e3d8746a3c59 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 20:42:19 +0100 Subject: [PATCH 09/14] Set clean. --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e9f8a0..74e785d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods @@ -47,17 +47,17 @@ repos: {{cookiecutter.project_slug}}/setup.cfg )$ - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.205 + rev: v0.0.241 hooks: - id: ruff args: [hooks, tests] pass_filenames: false - repo: https://github.com/dosisod/refurb - rev: v1.9.1 + rev: v1.10.0 hooks: - id: refurb args: [--ignore, FURB126] From 42480e10ec28823f303516b863408a1e6a641f68 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 20:45:30 +0100 Subject: [PATCH 10/14] to changes. --- docs/source/changes.md | 7 ++++++- hooks/post_gen_project.py | 1 - pyproject.toml | 2 ++ tests/test_cookie.py | 12 ++++++------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index 745699c..2ce32cc 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -3,7 +3,12 @@ This is a record of all past cookiecutter-pytask-project releases and what went into them in reverse chronological order. -## 1.4.0 - 2023-xx-xx +## 1.5.0 - 2023-02-04 + +- {pull}`33` fixes some small things. (Thanks to @hmgaudecker!) +- {pull}`34` adds dependabot to update Github Actions. + +## 1.4.0 - 2023-01-01 - {pull}`29` adds ruff and refurb to pre-commits and fixes CI banner. diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index c8c4955..efe9511 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -60,7 +60,6 @@ def main() -> None: ) if "{{ cookiecutter.create_conda_environment_at_finish }}" == "yes": - if shutil.which("mamba") is not None: conda_exe = shutil.which("mamba") else: diff --git a/pyproject.toml b/pyproject.toml index 40511c0..0d65a3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,8 @@ extend-ignore = [ [tool.ruff.per-file-ignores] "tests/*" = ["D", "ANN"] +"hooks/post_gen_project.py" = ["PLR0133"] +"hooks/*" = ["INP001"] [tool.ruff.pydocstyle] diff --git a/tests/test_cookie.py b/tests/test_cookie.py index d8cb6fc..a505b5a 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -8,7 +8,7 @@ _PYTHON_VERSION = ".".join(map(str, sys.version_info[:2])) -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_bake_project(cookies): result = cookies.bake( extra_context={"project_slug": "helloworld", "python_version": _PYTHON_VERSION} @@ -20,7 +20,7 @@ def test_bake_project(cookies): assert result.project_path.is_dir() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_readthedocs(cookies): result = cookies.bake( extra_context={ @@ -39,7 +39,7 @@ def test_remove_readthedocs(cookies): assert "readthedocs" not in readme -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_github_actions(cookies): result = cookies.bake( extra_context={"add_github_actions": "no", "python_version": _PYTHON_VERSION} @@ -55,7 +55,7 @@ def test_remove_github_actions(cookies): assert "github/workflow/status" not in readme -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_tox(cookies): result = cookies.bake( extra_context={"add_tox": "no", "python_version": _PYTHON_VERSION} @@ -71,7 +71,7 @@ def test_remove_tox(cookies): assert not tox.exists() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() def test_remove_license(cookies): result = cookies.bake( extra_context={ @@ -88,7 +88,7 @@ def test_remove_license(cookies): assert not license_.exists() -@pytest.mark.end_to_end +@pytest.mark.end_to_end() @pytest.mark.skipif(os.environ.get("CI") is None, reason="Run only in CI.") def test_check_conda_environment_creation_and_run_all_checks(cookies): """Test that the conda environment is created and pre-commit passes.""" From 6b7dc06234601a4b9b4ca483a91cb2c4027277cb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 4 Feb 2023 19:47:40 +0000 Subject: [PATCH 11/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- hooks/pre_gen_project.py | 3 ++- tests/test_cookie.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 80cadc6..986ff3d 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -44,7 +44,8 @@ def main() -> None: if not re.match(PYTHONVERSION_REGEX, python_version): raise ValueError( EXCEPTION_MSG_PYTHONVERSION.format( - min_python_version=PYTHONVERSION_MIN, python_version=python_version, + min_python_version=PYTHONVERSION_MIN, + python_version=python_version, ), ) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index b93b669..28db28c 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -108,7 +108,9 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): # Switch branch before pre-commit because otherwise failure because on main # branch. subprocess.run( - ("git", "checkout", "-b", "test"), cwd=result.project_path, check=True, + ("git", "checkout", "-b", "test"), + cwd=result.project_path, + check=True, ) # Check linting, but not on the first try since formatters fix stuff. From b88d46ea2e80ca1283fcb2308298c06211b3d242 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 20:48:19 +0100 Subject: [PATCH 12/14] Update innner pre-commit. --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index f05aa76..4d341aa 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: hooks: - id: setup-cfg-fmt - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/PyCQA/docformatter @@ -48,11 +48,11 @@ repos: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] {% if cookiecutter.python_version in ["3.10", "3.11", "3.12"] %}- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.205 + rev: v0.0.241 hooks: - id: ruff - repo: https://github.com/dosisod/refurb - rev: v1.9.1 + rev: v1.10.0 hooks: - id: refurb args: [--ignore, FURB126] From 93778193dc843c7de2e280e617e6407e067bfe79 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 20:50:16 +0100 Subject: [PATCH 13/14] Fix. --- hooks/post_gen_project.py | 6 ++---- hooks/pre_gen_project.py | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ad9a3e7..efe9511 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -39,9 +39,7 @@ def main() -> None: remove_file(project_path, ".readthedocs.yaml") subprocess.run( - ("git", "init", "--initial-branch", "main"), - check=True, - capture_output=True, + ("git", "init", "--initial-branch", "main"), check=True, capture_output=True ) if "{{ cookiecutter.make_initial_commit }}" == "yes": @@ -83,7 +81,7 @@ def main() -> None: else: warnings.warn( "conda environment could not be created since no conda or mamba " - "executable was found.", + "executable was found." ) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 986ff3d..66e93ac 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -36,7 +36,7 @@ def main() -> None: if not re.match(ENVIRON_REGEX, environment_name): raise ValueError( - EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name), + EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name) ) python_version = "{{ cookiecutter.python_version }}" @@ -44,8 +44,7 @@ def main() -> None: if not re.match(PYTHONVERSION_REGEX, python_version): raise ValueError( EXCEPTION_MSG_PYTHONVERSION.format( - min_python_version=PYTHONVERSION_MIN, - python_version=python_version, + min_python_version=PYTHONVERSION_MIN, python_version=python_version ), ) From bc1fb9cb933909e65a2155259e96d23d1b2bf146 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sat, 4 Feb 2023 21:04:12 +0100 Subject: [PATCH 14/14] Fix. --- {{cookiecutter.project_slug}}/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 5365997..05f08af 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -61,6 +61,7 @@ extend-ignore = [ [tool.ruff.per-file-ignores] "tests/*" = ["D", "ANN"] +"docs/source/conf.py" = ["INP001"] [tool.ruff.pydocstyle]