diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00fa12e..48a94b2 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'] @@ -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.2.2 - hooks: - - id: pyupgrade - args: [--py37-plus] - repo: https://github.com/asottile/reorder_python_imports rev: v3.9.0 hooks: @@ -52,44 +47,26 @@ 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 +- 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.5.0 + 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: @@ -104,10 +81,6 @@ repos: "{{cookiecutter.project_slug}}/tests/test_import.py" ] pass_filenames: false -- repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell - repo: https://github.com/executablebooks/mdformat rev: 0.7.16 hooks: @@ -141,13 +114,9 @@ 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.990' + rev: 'v0.991' hooks: - id: mypy args: [ 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/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 diff --git a/pyproject.toml b/pyproject.toml index cadab6b..82bc87f 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,41 @@ 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", + "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" 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}}/.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" 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 =