From be33f7bf4232391bc02cb4af71eb85063143748f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:36:07 -0700 Subject: [PATCH 1/9] Update pre-commit --- .pre-commit-config.yaml | 18 +++++++++--------- pyproject.toml | 17 +++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c5fbb02..2b8164a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.8.0 hooks: - id: black @@ -17,13 +17,13 @@ repos: args: [--add-import=from __future__ import annotations] - repo: https://github.com/PyCQA/bandit - rev: 1.7.6 + rev: 1.7.10 hooks: - id: bandit args: ["--skip=B101,B404,B603"] - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 additional_dependencies: @@ -41,7 +41,7 @@ repos: - id: python-check-blanket-noqa - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-case-conflict - id: check-executables-have-shebangs @@ -54,7 +54,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.10.1 hooks: - id: mypy args: @@ -69,17 +69,17 @@ repos: pass_filenames: false - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.6.0 + rev: 2.2.4 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.15 + rev: v0.19 hooks: - id: validate-pyproject - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell args: [--ignore-words-list=commitish] diff --git a/pyproject.toml b/pyproject.toml index 0813d12..62f75c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,8 @@ requires = [ [project] name = "cherry-picker" readme = "README.md" -maintainers = [{ name = "Python Core Developers", email = "core-workflow@python.org" }] -authors = [{ name = "Mariatta Wijaya", email = "mariatta@python.org" }] +maintainers = [ { name = "Python Core Developers", email = "core-workflow@python.org" } ] +authors = [ { name = "Mariatta Wijaya", email = "mariatta@python.org" } ] requires-python = ">=3.8" classifiers = [ "Intended Audience :: Developers", @@ -26,21 +26,18 @@ dynamic = [ "version", ] dependencies = [ - "cffi>=v1.17.0rc1", # remove once v1.17.0 is out; add 3.13 classifier above (see #127) + "cffi>=1.17.0rc1", # remove once v1.17.0 is out; add 3.13 classifier above (see #127) "click>=6", "gidgethub", "requests", - 'tomli>=1.1; python_version < "3.11"', + "tomli>=1.1; python_version<'3.11'", ] -[project.optional-dependencies] -dev = [ +optional-dependencies.dev = [ "pytest", "pytest-cov", ] -[project.urls] -"Homepage" = "https://github.com/python/cherry-picker" -[project.scripts] -cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli" +urls.Homepage = "https://github.com/python/cherry-picker" +scripts.cherry_picker = "cherry_picker.cherry_picker:cherry_pick_cli" [tool.hatch.version] source = "vcs" From d318e95366281b4cb04534886e9a4ff2b7b8fbab Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:37:38 -0700 Subject: [PATCH 2/9] Add Trove classifier for Python 3.13 --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 62f75c3..0a24792 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,13 +20,13 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dynamic = [ "description", "version", ] dependencies = [ - "cffi>=1.17.0rc1", # remove once v1.17.0 is out; add 3.13 classifier above (see #127) "click>=6", "gidgethub", "requests", @@ -49,3 +49,6 @@ local_scheme = "no-local-version" [tool.isort] profile = "black" + +[tool.pyproject-fmt] +max_supported_python = "3.13" From cbfe6c21f26a845fd4448bd577f5dd3e556139ae Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:39:45 -0700 Subject: [PATCH 3/9] Add tox-ini-fmt to pre-commit --- .pre-commit-config.yaml | 5 +++++ tox.ini | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b8164a..c11d645 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,11 @@ repos: hooks: - id: validate-pyproject + - repo: https://github.com/tox-dev/tox-ini-fmt + rev: 1.4.1 + hooks: + - id: tox-ini-fmt + - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: diff --git a/tox.ini b/tox.ini index d41abed..80648f5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,13 @@ [tox] -envlist = +requires = + tox>=4.2 +env_list = py{312, 311, 310, 39, 38} -isolated_build = true [testenv] -passenv = - FORCE_COLOR extras = dev +pass_env = + FORCE_COLOR commands = {envpython} -m pytest --cov cherry_picker --cov-report html --cov-report term --cov-report xml {posargs} From ee8378848abe2bda5ff7cdf36c29c23b761fa453 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:49:46 -0700 Subject: [PATCH 4/9] Replace Flake8 with Ruff --- .pre-commit-config.yaml | 38 ++++------------------------------ cherry_picker/cherry_picker.py | 2 +- pyproject.toml | 22 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c11d645..0bddd22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,45 +1,15 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.7 hooks: - - id: pyupgrade - args: [--py38-plus] + - id: ruff + args: [--exit-non-zero-on-fix] - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.8.0 hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - args: [--add-import=from __future__ import annotations] - - - repo: https://github.com/PyCQA/bandit - rev: 1.7.10 - hooks: - - id: bandit - args: ["--skip=B101,B404,B603"] - - - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 - additional_dependencies: - [ - flake8-2020, - flake8-bugbear, - flake8-comprehensions, - flake8-implicit-str-concat, - flake8-logging, - ] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 423c76f..89fc411 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -702,7 +702,7 @@ def is_mirror(self) -> bool: return out.startswith("true") -CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) +CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]} @click.command(context_settings=CONTEXT_SETTINGS) diff --git a/pyproject.toml b/pyproject.toml index 0a24792..e59c9bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,8 +47,26 @@ tag-pattern = '^cherry-picker-(?P[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)? [tool.hatch.version.raw-options] local_scheme = "no-local-version" -[tool.isort] -profile = "black" +[tool.ruff] +fix = true + +lint.select = [ + "C4", # flake8-comprehensions + "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging + "PGH", # pygrep-hooks + "S", # flake8-bandit + "YTT", # flake8-2020 +] + +lint.ignore = [ + "S101", # Use of assert detected + "S404", # subprocess module is possibly insecure + "S603", # subprocess call: check for execution of untrusted input +] +lint.per-file-ignores."cherry_picker/test_*.py" = [ + "S101", # Asserts allowed in tests +] [tool.pyproject-fmt] max_supported_python = "3.13" From 67bbdaf5d7d01ccd361c545be239897214c3329d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:51:22 -0700 Subject: [PATCH 5/9] Add more linting --- .pre-commit-config.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bddd22..71227b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,16 +13,28 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: + - id: check-added-large-files - id: check-case-conflict - id: check-executables-have-shebangs - id: check-merge-conflict - - id: check-json - id: check-toml - id: check-yaml - id: debug-statements - id: end-of-file-fixer + - id: forbid-submodules - id: trailing-whitespace + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.29.2 + hooks: + - id: check-dependabot + - id: check-github-workflows + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.1 + hooks: + - id: actionlint + - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.10.1 hooks: @@ -59,5 +71,10 @@ repos: - id: codespell args: [--ignore-words-list=commitish] + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + ci: autoupdate_schedule: quarterly From b350d8eba377b34a9aee90ef109482c755a510a7 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:38:09 -0700 Subject: [PATCH 6/9] Format with tox-ini-fmt --- tox.ini | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 8361eab..812ab48 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ requires = tox>=4.2 env_list = py{313, 312, 311, 310, 39} -isolated_build = true [testenv] extras = @@ -12,8 +11,8 @@ pass_env = FORCE_COLOR commands = {envpython} -m pytest \ - --cov cherry_picker \ - --cov-report html \ - --cov-report term \ - --cov-report xml \ - {posargs} + --cov cherry_picker \ + --cov-report html \ + --cov-report term \ + --cov-report xml \ + {posargs} From 07f9567ac940fd4e2251ba8d1e83796b33203c5a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:23:47 -0700 Subject: [PATCH 7/9] Add more linting --- pyproject.toml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e59c9bb..56ae257 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,14 +51,22 @@ local_scheme = "no-local-version" fix = true lint.select = [ - "C4", # flake8-comprehensions - "ISC", # flake8-implicit-str-concat - "LOG", # flake8-logging - "PGH", # pygrep-hooks - "S", # flake8-bandit - "YTT", # flake8-2020 + "C4", # flake8-comprehensions + "E", # pycodestyle errors + "F", # pyflakes errors + "I", # isort + "ICN", # flake8-import-conventions + "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging + "PGH", # pygrep-hooks + "PYI", # flake8-pyi + "RUF022", # unsorted-dunder-all + "RUF100", # unused noqa (yesqa) + "S", # flake8-bandit + "UP", # pyupgrade + "W", # pycodestyle warnings + "YTT", # flake8-2020 ] - lint.ignore = [ "S101", # Use of assert detected "S404", # subprocess module is possibly insecure From fad66b3eadaf5904a2ee0cd16241c002520b21dc Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:36:04 -0700 Subject: [PATCH 8/9] Require 'from __future__ import annotations' --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 56ae257..3c0d025 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,7 @@ lint.ignore = [ lint.per-file-ignores."cherry_picker/test_*.py" = [ "S101", # Asserts allowed in tests ] +lint.isort.required-imports = [ "from __future__ import annotations" ] [tool.pyproject-fmt] max_supported_python = "3.13" From 6f5419f8481268a2c36a79ddf1f590a990e4014b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:49:11 +0300 Subject: [PATCH 9/9] Remove it Co-authored-by: Alex Waygood --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3c0d025..121ff51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,9 +72,6 @@ lint.ignore = [ "S404", # subprocess module is possibly insecure "S603", # subprocess call: check for execution of untrusted input ] -lint.per-file-ignores."cherry_picker/test_*.py" = [ - "S101", # Asserts allowed in tests -] lint.isort.required-imports = [ "from __future__ import annotations" ] [tool.pyproject-fmt]