From 9b0bedabf1d6d85008ab8d944f440f5ff2900416 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 01:07:30 +0000 Subject: [PATCH 1/7] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.269 → v0.0.270](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.269...v0.0.270) - [github.com/shellcheck-py/shellcheck-py: v0.9.0.2 → v0.9.0.5](https://github.com/shellcheck-py/shellcheck-py/compare/v0.9.0.2...v0.9.0.5) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50e5c7e9..7a4d4fdb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.269 + rev: v0.0.270 hooks: - id: ruff args: [--fix] @@ -99,7 +99,7 @@ repos: types: [python] exclude: tests/ - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.2 + rev: v0.9.0.5 hooks: - id: shellcheck - repo: https://github.com/openstack/bashate From 65178f3e4f1ba997306ff8b3405111e37978bd3f Mon Sep 17 00:00:00 2001 From: "W. Augusto Andreoli" Date: Sun, 2 Jul 2023 17:18:26 +0200 Subject: [PATCH 2/7] feat: drop support for Python 3.7 It has reached EOL: https://peps.python.org/pep-0537/ --- .github/workflows/python.yaml | 2 +- .pre-commit-config.yaml | 2 +- .tool-versions | 2 +- README.rst | 2 - docs/ideas/text.toml | 2 +- docs/ideas/yaml/contains.toml | 4 +- docs/ideas/yaml/merge_lists/merged_style.toml | 2 +- docs/ideas/yaml/merge_lists/py37.toml | 2 - docs/library.rst | 2 - docs/nitpick_section.rst | 2 +- poetry.lock | 68 ++----------------- pyproject.toml | 11 ++- src/nitpick/core.py | 2 +- src/nitpick/flake8.py | 2 +- src/nitpick/resources/python/37.toml | 5 -- .../resources/python/github-workflow.toml | 2 +- src/nitpick/style/fetchers/github.py | 2 +- src/nitpick/style/fetchers/pypackage.py | 4 +- tasks.py | 10 +-- tests/test_builtin/python/37/pyproject.toml | 2 - .../.github/workflows/python.yaml | 1 - tests/test_builtin/real.yaml | 2 +- tests/test_yaml/existing-actual.yaml | 2 +- tests/test_yaml/new-desired.toml | 2 +- tests/test_yaml/new-expected.yaml | 1 - tests/test_yaml_github_workflows.py | 1 - ...dd-elements-that-do-not-exist-desired.toml | 2 +- ...d-elements-that-do-not-exist-expected.yaml | 2 +- tox.ini | 9 +-- 29 files changed, 33 insertions(+), 119 deletions(-) delete mode 100644 docs/ideas/yaml/merge_lists/py37.toml delete mode 100644 src/nitpick/resources/python/37.toml delete mode 100644 tests/test_builtin/python/37/pyproject.toml diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index dbd3e48a..7cdc81f3 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11", "3.10", "3.9", "3.8", "3.7"] + python-version: ["3.11", "3.10", "3.9", "3.8"] # ubuntu-latest is being moved from ubuntu-18.04 to ubuntu-20.04 # See https://github.com/actions/virtual-environments/issues/1816 os: [ubuntu-latest, windows-latest, macos-latest] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a4d4fdb..1ba22cbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ # https://pre-commit.com/#top_level-default_language_version default_language_version: - python: python3.7 + python: python3.8 # https://pre-commit.ci/#configuration ci: diff --git a/.tool-versions b/.tool-versions index 560efce7..0a9cc560 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -poetry 1.5.0 +poetry 1.5.1 pre-commit 3.3.2 diff --git a/README.rst b/README.rst index 7cfa939c..cba604f1 100644 --- a/README.rst +++ b/README.rst @@ -253,8 +253,6 @@ python - Python 3.10 * - `py://nitpick/resources/python/311 `_ - Python 3.11 - * - `py://nitpick/resources/python/37 `_ - - Python 3.7 * - `py://nitpick/resources/python/38 `_ - Python 3.8 * - `py://nitpick/resources/python/39 `_ diff --git a/docs/ideas/text.toml b/docs/ideas/text.toml index ee032f65..70f4c863 100644 --- a/docs/ideas/text.toml +++ b/docs/ideas/text.toml @@ -113,7 +113,7 @@ library identifier: "company-shared-pipelines@master", retriever: modernSCM([ # Only one of block/line/lines should be accepted. Accepting more than one makes no sense. block = """ -FROM python:3.7 +FROM python:3.8 ENV TERM xterm-256color ENV APP_USER=johndoe diff --git a/docs/ideas/yaml/contains.toml b/docs/ideas/yaml/contains.toml index 89b356e3..550c94b6 100644 --- a/docs/ideas/yaml/contains.toml +++ b/docs/ideas/yaml/contains.toml @@ -3,7 +3,7 @@ [[".github/workflows/python.yaml".contains]] __jmespath = "jobs.build.strategy.matrix" os = ["ubuntu-latest", "macos-latest", "windows-latest"] -"python-version" = ["3.11", "3.10", "3.9", "3.8", "3.7"] +"python-version" = ["3.11", "3.10", "3.9", "3.8"] # 3. Same as item 4 on "jmespath-on-section.toml", but with a different syntax. [[".github/workflows/python.yaml".contains]] @@ -56,7 +56,7 @@ __yaml = "- uses: actions/checkout@v2" [[".github/workflows/python.yaml".contains_sorted]] __jmespath = "jobs.build.strategy.matrix" os = ["ubuntu-latest", "macos-latest", "windows-latest"] -"python-version" = ["3.11", "3.10", "3.9", "3.8", "3.7"] +"python-version" = ["3.11", "3.10", "3.9", "3.8"] [[".github/workflows/python.yaml".contains_sorted]] __jmespath = "jobs.build" diff --git a/docs/ideas/yaml/merge_lists/merged_style.toml b/docs/ideas/yaml/merge_lists/merged_style.toml index 112c6069..fd6c2cd7 100644 --- a/docs/ideas/yaml/merge_lists/merged_style.toml +++ b/docs/ideas/yaml/merge_lists/merged_style.toml @@ -1,4 +1,4 @@ # This should be the result of a parent style including all the styles in this directory [".github/workflows/python.yaml".jobs.build.strategy.matrix] os = ["ubuntu-latest", "macos-latest", "windows-latest"] -"python-version" = ["3.11", "3.10", "3.9", "3.8", "3.7"] +"python-version" = ["3.11", "3.10", "3.9", "3.8"] diff --git a/docs/ideas/yaml/merge_lists/py37.toml b/docs/ideas/yaml/merge_lists/py37.toml deleted file mode 100644 index 88297543..00000000 --- a/docs/ideas/yaml/merge_lists/py37.toml +++ /dev/null @@ -1,2 +0,0 @@ -[".github/workflows/python.yaml".jobs.build.strategy.matrix] -"python-version" = ["3.7"] diff --git a/docs/library.rst b/docs/library.rst index 672bf9e2..4d60b2d6 100644 --- a/docs/library.rst +++ b/docs/library.rst @@ -94,8 +94,6 @@ python - Python 3.10 * - :gitref:`py://nitpick/resources/python/311 ` - Python 3.11 - * - :gitref:`py://nitpick/resources/python/37 ` - - Python 3.7 * - :gitref:`py://nitpick/resources/python/38 ` - Python 3.8 * - :gitref:`py://nitpick/resources/python/39 ` diff --git a/docs/nitpick_section.rst b/docs/nitpick_section.rst index 0add2eca..08063b37 100644 --- a/docs/nitpick_section.rst +++ b/docs/nitpick_section.rst @@ -70,7 +70,7 @@ Example of usage: :gitref:`Nitpick's default style `. .. code-block:: toml [nitpick.styles] - include = ["styles/python37", "styles/poetry"] + include = ["styles/python38", "styles/poetry"] The styles will be merged following the sequence in the list. The ``.toml`` extension for each referenced file can be onitted. diff --git a/poetry.lock b/poetry.lock index cca423cd..4bc78520 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "alabaster" @@ -36,7 +36,6 @@ files = [ [package.dependencies] lazy-object-proxy = ">=1.4.0" setuptools = ">=20.0" -typed-ast = {version = ">=1.4.0,<2.0", markers = "implementation_name == \"cpython\" and python_version < \"3.8\""} typing-extensions = {version = ">=3.10", markers = "python_version < \"3.10\""} wrapt = ">=1.11,<2" @@ -68,9 +67,6 @@ files = [ {file = "attrs-23.1.0.tar.gz", hash = "sha256:6279836d581513a26f1bf235f9acd333bc9115683f14f7e8fae46c98fc50e015"}, ] -[package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} - [package.extras] cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] dev = ["attrs[docs,tests]", "pre-commit"] @@ -129,7 +125,6 @@ files = [ [package.dependencies] attrs = ">=20" exceptiongroup = {version = "*", markers = "python_version < \"3.11\""} -typing_extensions = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "certifi" @@ -169,7 +164,6 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -193,9 +187,6 @@ files = [ {file = "ConfigUpdater-3.1.1.tar.gz", hash = "sha256:46f0c74d73efa723776764b43c9739f68052495dd3d734319c1d0eb58511f15b"}, ] -[package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} - [package.extras] testing = ["flake8", "pytest", "pytest-cov", "pytest-virtualenv", "pytest-xdist", "sphinx"] @@ -366,7 +357,6 @@ files = [ ] [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} mccabe = ">=0.6.0,<0.7.0" pycodestyle = ">=2.7.0,<2.8.0" pyflakes = ">=2.3.0,<2.4.0" @@ -383,7 +373,6 @@ files = [ ] [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} six = ">=1.12,<2.0" [[package]] @@ -472,7 +461,7 @@ files = [ name = "importlib-metadata" version = "4.13.0" description = "Read metadata from Python packages" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "importlib_metadata-4.13.0-py3-none-any.whl", hash = "sha256:8a8a81bcf996e74fee46f0d16bd3eaa382a7eb20fd82445c3ad11f4090334116"}, @@ -480,7 +469,6 @@ files = [ ] [package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] @@ -629,10 +617,8 @@ files = [ [package.dependencies] attrs = ">=17.4.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] @@ -928,9 +914,6 @@ files = [ {file = "platformdirs-3.1.1.tar.gz", hash = "sha256:024996549ee88ec1a9aa99ff7f8fc819bb59e2c3477b410d90a16d32d6e707aa"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.4", markers = "python_version < \"3.8\""} - [package.extras] docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] @@ -946,9 +929,6 @@ files = [ {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, ] -[package.dependencies] -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} - [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] @@ -1116,7 +1096,6 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" @@ -1359,7 +1338,6 @@ files = [ pyyaml = "*" requests = ">=2.22.0,<3.0" types-PyYAML = "*" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} urllib3 = ">=1.25.10" [package.extras] @@ -1397,8 +1375,7 @@ files = [ {file = "ruamel.yaml.clib-0.2.7-cp310-cp310-win32.whl", hash = "sha256:763d65baa3b952479c4e972669f679fe490eee058d5aa85da483ebae2009d231"}, {file = "ruamel.yaml.clib-0.2.7-cp310-cp310-win_amd64.whl", hash = "sha256:d000f258cf42fec2b1bbf2863c61d7b8918d31ffee905da62dede869254d3b8a"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:045e0626baf1c52e5527bd5db361bc83180faaba2ff586e763d3d5982a876a9e"}, - {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_13_0_arm64.whl", hash = "sha256:1a6391a7cabb7641c32517539ca42cf84b87b667bad38b78d4d42dd23e957c81"}, - {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-manylinux2014_aarch64.whl", hash = "sha256:9c7617df90c1365638916b98cdd9be833d31d337dbcd722485597b43c4a215bf"}, + {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_12_6_arm64.whl", hash = "sha256:721bc4ba4525f53f6a611ec0967bdcee61b31df5a56801281027a3a6d1c2daf5"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:41d0f1fa4c6830176eef5b276af04c89320ea616655d01327d5ce65e50575c94"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-win32.whl", hash = "sha256:f6d3d39611ac2e4f62c3128a9eed45f19a6608670c5a2f4f07f24e8de3441d38"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-win_amd64.whl", hash = "sha256:da538167284de58a52109a9b89b8f6a53ff8437dd6dc26d33b57bf6699153122"}, @@ -1756,39 +1733,6 @@ files = [ [package.extras] test = ["pytest"] -[[package]] -name = "typed-ast" -version = "1.5.2" -description = "a fork of Python 2 and 3 ast modules with type comment support" -optional = true -python-versions = ">=3.6" -files = [ - {file = "typed_ast-1.5.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:183b183b7771a508395d2cbffd6db67d6ad52958a5fdc99f450d954003900266"}, - {file = "typed_ast-1.5.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:676d051b1da67a852c0447621fdd11c4e104827417bf216092ec3e286f7da596"}, - {file = "typed_ast-1.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bc2542e83ac8399752bc16e0b35e038bdb659ba237f4222616b4e83fb9654985"}, - {file = "typed_ast-1.5.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:74cac86cc586db8dfda0ce65d8bcd2bf17b58668dfcc3652762f3ef0e6677e76"}, - {file = "typed_ast-1.5.2-cp310-cp310-win_amd64.whl", hash = "sha256:18fe320f354d6f9ad3147859b6e16649a0781425268c4dde596093177660e71a"}, - {file = "typed_ast-1.5.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:31d8c6b2df19a777bc8826770b872a45a1f30cfefcfd729491baa5237faae837"}, - {file = "typed_ast-1.5.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:963a0ccc9a4188524e6e6d39b12c9ca24cc2d45a71cfdd04a26d883c922b4b78"}, - {file = "typed_ast-1.5.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:0eb77764ea470f14fcbb89d51bc6bbf5e7623446ac4ed06cbd9ca9495b62e36e"}, - {file = "typed_ast-1.5.2-cp36-cp36m-win_amd64.whl", hash = "sha256:294a6903a4d087db805a7656989f613371915fc45c8cc0ddc5c5a0a8ad9bea4d"}, - {file = "typed_ast-1.5.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:26a432dc219c6b6f38be20a958cbe1abffcc5492821d7e27f08606ef99e0dffd"}, - {file = "typed_ast-1.5.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7407cfcad702f0b6c0e0f3e7ab876cd1d2c13b14ce770e412c0c4b9728a0f88"}, - {file = "typed_ast-1.5.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f30ddd110634c2d7534b2d4e0e22967e88366b0d356b24de87419cc4410c41b7"}, - {file = "typed_ast-1.5.2-cp37-cp37m-win_amd64.whl", hash = "sha256:8c08d6625bb258179b6e512f55ad20f9dfef019bbfbe3095247401e053a3ea30"}, - {file = "typed_ast-1.5.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:90904d889ab8e81a956f2c0935a523cc4e077c7847a836abee832f868d5c26a4"}, - {file = "typed_ast-1.5.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:bbebc31bf11762b63bf61aaae232becb41c5bf6b3461b80a4df7e791fabb3aca"}, - {file = "typed_ast-1.5.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c29dd9a3a9d259c9fa19d19738d021632d673f6ed9b35a739f48e5f807f264fb"}, - {file = "typed_ast-1.5.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:58ae097a325e9bb7a684572d20eb3e1809802c5c9ec7108e85da1eb6c1a3331b"}, - {file = "typed_ast-1.5.2-cp38-cp38-win_amd64.whl", hash = "sha256:da0a98d458010bf4fe535f2d1e367a2e2060e105978873c04c04212fb20543f7"}, - {file = "typed_ast-1.5.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:33b4a19ddc9fc551ebabca9765d54d04600c4a50eda13893dadf67ed81d9a098"}, - {file = "typed_ast-1.5.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1098df9a0592dd4c8c0ccfc2e98931278a6c6c53cb3a3e2cf7e9ee3b06153344"}, - {file = "typed_ast-1.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42c47c3b43fe3a39ddf8de1d40dbbfca60ac8530a36c9b198ea5b9efac75c09e"}, - {file = "typed_ast-1.5.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f290617f74a610849bd8f5514e34ae3d09eafd521dceaa6cf68b3f4414266d4e"}, - {file = "typed_ast-1.5.2-cp39-cp39-win_amd64.whl", hash = "sha256:df05aa5b241e2e8045f5f4367a9f6187b09c4cdf8578bb219861c4e27c443db5"}, - {file = "typed_ast-1.5.2.tar.gz", hash = "sha256:525a2d4088e70a9f75b08b3f87a51acc9cde640e19cc523c7e41aa355564ae27"}, -] - [[package]] name = "types-pyyaml" version = "6.0.12.8" @@ -1804,7 +1748,7 @@ files = [ name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, @@ -2009,5 +1953,5 @@ test = ["freezegun", "pytest", "pytest-cov", "pytest-datadir", "pytest-socket", [metadata] lock-version = "2.0" -python-versions = "^3.7" -content-hash = "7a282a4343b7e8e99b5572e20b085d81a94c135a3ab982326df4933e6497a1d6" +python-versions = "^3.8" +content-hash = "7c648727e43efdecba93dc7fe931f5d82beb62f73920a926b2a6e58d29854baa" diff --git a/pyproject.toml b/pyproject.toml index b7cd918f..b906cad7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ # Use the default style and override some things (like the Python version) style = [ "nitpick-style", - "py://nitpick/resources/python/37.toml", + "py://nitpick/resources/python/38.toml", "py://nitpick/resources/python/stable.toml" ] @@ -47,7 +47,7 @@ toml = "nitpick.plugins.toml" yaml = "nitpick.plugins.yaml" [tool.poetry.dependencies] -python = "^3.7" +python = "^3.8" # TODO: build: upgrading importlib-metadata to 4.10.1 downgrades the following packages: # • Updating importlib-metadata (4.2.0 -> 4.10.1) # • Updating pycodestyle (2.8.0 -> 2.7.0) @@ -76,14 +76,11 @@ pluggy = "*" autorepr = "*" loguru = "*" ConfigUpdater = "*" -importlib-resources = { version = "*", python = ">=3.7, <3.9" } +importlib-resources = { version = "*", python = ">=3.8, <3.9" } flatten-dict = "*" dpath = "*" furl = "*" StrEnum = "*" -# To avoid this error on python3.7: AttributeError: 'EntryPoints' object has no attribute 'get' -# https://importlib-metadata.readthedocs.io/en/latest/history.html#v5-0-0 -importlib-metadata = {version = "<5.0", python = "<3.8"} # TODO: chore: move to dependency groups once the feature is on a stable version of Poetry # https://python-poetry.org/docs/master/managing-dependencies/#dependency-groups @@ -147,7 +144,7 @@ ignore = [ line-length = 120 # https://beta.ruff.rs/docs/settings/#target-version -target-version = "py37" +target-version = "py38" # https://beta.ruff.rs/docs/settings/#src src = ["src"] diff --git a/src/nitpick/core.py b/src/nitpick/core.py index 9046af5c..adf6cfef 100644 --- a/src/nitpick/core.py +++ b/src/nitpick/core.py @@ -31,7 +31,7 @@ def __init__(self) -> None: self.offline: bool = False @classmethod - @lru_cache() + @lru_cache def singleton(cls) -> "Nitpick": """Return a single instance of the class.""" Nitpick._allow_init = True diff --git a/src/nitpick/flake8.py b/src/nitpick/flake8.py index 878c3d49..6cf90c73 100644 --- a/src/nitpick/flake8.py +++ b/src/nitpick/flake8.py @@ -61,7 +61,7 @@ def collect_errors(self) -> Iterator[Fuss]: return [] @staticmethod - @lru_cache() # To avoid calling this function twice in the same process + @lru_cache # To avoid calling this function twice in the same process def add_options(option_manager: OptionManager): """Add the offline option.""" option_manager.add_option( diff --git a/src/nitpick/resources/python/37.toml b/src/nitpick/resources/python/37.toml deleted file mode 100644 index 35a44f2f..00000000 --- a/src/nitpick/resources/python/37.toml +++ /dev/null @@ -1,5 +0,0 @@ -[nitpick.meta] -name = "Python 3.7" - -["pyproject.toml".tool.poetry.dependencies] -python = "^3.7" diff --git a/src/nitpick/resources/python/github-workflow.toml b/src/nitpick/resources/python/github-workflow.toml index 30ca9652..a23416cb 100644 --- a/src/nitpick/resources/python/github-workflow.toml +++ b/src/nitpick/resources/python/github-workflow.toml @@ -11,7 +11,7 @@ fail-fast = false [".github/workflows/python.yaml".jobs.build.strategy.matrix] os = ["ubuntu-latest", "windows-latest", "macos-latest"] -python-version = ["3.11", "3.10", "3.9", "3.8", "3.7"] +python-version = ["3.11", "3.10", "3.9", "3.8"] [".github/workflows/python.yaml".jobs.build] name = "${{ matrix.python-version }} ${{ matrix.os }}" diff --git a/src/nitpick/style/fetchers/github.py b/src/nitpick/style/fetchers/github.py index 430618fd..068dedf9 100644 --- a/src/nitpick/style/fetchers/github.py +++ b/src/nitpick/style/fetchers/github.py @@ -135,7 +135,7 @@ def _build_url(self, scheme: str) -> furl: API_SESSION = Session() -@lru_cache() +@lru_cache def get_default_branch(api_url: str, *, token: str | None = None) -> str: """Get the default branch from the GitHub repo using the API. diff --git a/src/nitpick/style/fetchers/pypackage.py b/src/nitpick/style/fetchers/pypackage.py index 292f8f50..c671d27c 100644 --- a/src/nitpick/style/fetchers/pypackage.py +++ b/src/nitpick/style/fetchers/pypackage.py @@ -18,13 +18,13 @@ from pathlib import Path -@lru_cache() +@lru_cache def builtin_resources_root() -> Path: """Built-in resources root.""" return compat.files("nitpick.resources") -@lru_cache() +@lru_cache def repo_root() -> Path: """Repository root, 3 levels up from the resources root.""" return builtin_resources_root().parent.parent.parent diff --git a/tasks.py b/tasks.py index b6f4110a..bf2a9613 100644 --- a/tasks.py +++ b/tasks.py @@ -128,17 +128,9 @@ def install(c, deps=True, hooks=False, version=""): if not version: version = minimum - # pre-commit fails on 3.7: - # ModuleNotFoundError: No module named 'importlib.metadata' - # Support was dropped, but I couldn't find it in the documentation - explanation = "" - if version == "3.7": - version = "3.8" - explanation = " (3.7 is not supported by pre-commit https://github.com/pre-commit/pre-commit/pull/2655)" - print( f"{COLOR_GREEN}Nitpick runs in Python {minimum} and later;" - f" setting up version {version} for development{explanation}{COLOR_NONE}" + f" setting up version {version} for development{COLOR_NONE}" ) c.run(f"poetry env use python{version}") c.run("poetry install -E test -E lint -E doc --sync") diff --git a/tests/test_builtin/python/37/pyproject.toml b/tests/test_builtin/python/37/pyproject.toml deleted file mode 100644 index 4fc262c4..00000000 --- a/tests/test_builtin/python/37/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.poetry.dependencies] -python = "^3.7" diff --git a/tests/test_builtin/python/github-workflow/.github/workflows/python.yaml b/tests/test_builtin/python/github-workflow/.github/workflows/python.yaml index 9f312729..fdfd8e7b 100644 --- a/tests/test_builtin/python/github-workflow/.github/workflows/python.yaml +++ b/tests/test_builtin/python/github-workflow/.github/workflows/python.yaml @@ -16,7 +16,6 @@ jobs: - '3.10' - '3.9' - '3.8' - - '3.7' name: ${{ matrix.python-version }} ${{ matrix.os }} runs-on: ${{ matrix.os }} env: diff --git a/tests/test_builtin/real.yaml b/tests/test_builtin/real.yaml index 76952492..90bd9bac 100644 --- a/tests/test_builtin/real.yaml +++ b/tests/test_builtin/real.yaml @@ -39,7 +39,7 @@ repos: rev: v2.31.0 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] - repo: https://github.com/myint/autoflake rev: v1.4 hooks: diff --git a/tests/test_yaml/existing-actual.yaml b/tests/test_yaml/existing-actual.yaml index d0c23a5e..a69a8f27 100644 --- a/tests/test_yaml/existing-actual.yaml +++ b/tests/test_yaml/existing-actual.yaml @@ -1,6 +1,6 @@ # Root comment python: - version: 3.7 # This comment should be kept + version: 3.8 # This comment should be kept install: - method: pip path: . diff --git a/tests/test_yaml/new-desired.toml b/tests/test_yaml/new-desired.toml index 845e0b23..9430c6ad 100644 --- a/tests/test_yaml/new-desired.toml +++ b/tests/test_yaml/new-desired.toml @@ -12,7 +12,7 @@ with = {"python-version" = "${{ matrix.python-version }}"} [".github/workflows/python.yaml".jobs.build.strategy.matrix] os = ["ubuntu-latest", "macos-latest", "windows-latest"] -"python-version" = ["3.11", "3.10", "3.9", "3.8", "3.7"] +"python-version" = ["3.11", "3.10", "3.9", "3.8"] [".github/workflows/python.yaml".jobs.build] "runs-on" = "${{ matrix.os }}" diff --git a/tests/test_yaml/new-expected.yaml b/tests/test_yaml/new-expected.yaml index 5daf05cc..8e378b7b 100644 --- a/tests/test_yaml/new-expected.yaml +++ b/tests/test_yaml/new-expected.yaml @@ -17,5 +17,4 @@ jobs: - '3.10' - '3.9' - '3.8' - - '3.7' runs-on: ${{ matrix.os }} diff --git a/tests/test_yaml_github_workflows.py b/tests/test_yaml_github_workflows.py index 7525c151..ebb3717e 100644 --- a/tests/test_yaml_github_workflows.py +++ b/tests/test_yaml_github_workflows.py @@ -58,7 +58,6 @@ def test_list_of_scalars_only_add_elements_that_do_not_exist(tmp_path, datadir): os: - ubuntu-latest python-version: - - '3.7' - '3.10' - '3.11' """, diff --git a/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-desired.toml b/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-desired.toml index 5f5cb454..917619df 100644 --- a/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-desired.toml +++ b/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-desired.toml @@ -1,3 +1,3 @@ [".github/workflows/python.yaml".jobs.build.strategy.matrix] os = ["ubuntu-latest", "windows-latest", "macos-latest"] -python-version = ["3.7", "3.8", "3.9", "3.10", "3.11"] +python-version = ["3.8", "3.9", "3.10", "3.11"] diff --git a/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-expected.yaml b/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-expected.yaml index ef997aca..d04e4b1e 100644 --- a/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-expected.yaml +++ b/tests/test_yaml_github_workflows/scalar-add-elements-that-do-not-exist-expected.yaml @@ -7,7 +7,7 @@ jobs: # ubuntu-latest is being moved from ubuntu-18.04 to ubuntu-20.04 # See https://github.com/actions/virtual-environments/issues/1816 os: [windows-latest, gentoo, macos-latest, arch-linux, ubuntu-latest] - python-version: ["3.8", "3.9", "2.7", '3.7', '3.10', '3.11'] + python-version: ["3.8", "3.9", "2.7", '3.10', '3.11'] runs-on: ${{ matrix.os }} env: PYTHONUNBUFFERED: 1 diff --git a/tox.ini b/tox.ini index 9271cb61..3295637c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] # https://tox.readthedocs.io/en/latest/config.html isolated_build = True -envlist = clean,lint,py311,py310,py39,py38,py37,docs,report +envlist = clean,lint,py311,py310,py39,py38,docs,report # https://github.com/ymyzk/tox-gh-actions breaks with "InterpreterNotFound" when there is a "requires" key # clean: commands succeeded @@ -9,9 +9,6 @@ envlist = clean,lint,py311,py310,py39,py38,py37,docs,report # ERROR: py310: InterpreterNotFound: python3.10 # py39: commands succeeded # py38: commands succeeded -# ERROR: py37: InterpreterNotFound: python3.7 -# docs: commands succeeded -# report: commands succeeded requires = # Installing with "requires" even though it's not the recommended option # https://github.com/enpaul/tox-poetry-installer/#installing @@ -21,8 +18,8 @@ requires = description = Run tests with pytest and coverage extras = test depends = - {py311,py310,py39,py38,py37}: clean - report: py311,py310,py39,py38,py37 + {py311,py310,py39,py38}: clean + report: py311,py310,py39,py38 setenv = PY_IGNORE_IMPORTMISMATCH = 1 commands = From 45baf32859121f97958cc1155b00cfb5218b0c3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 2 Jul 2023 15:25:29 +0000 Subject: [PATCH 3/7] build(deps-dev): bump ipython from 7.34.0 to 8.10.0 Bumps [ipython](https://github.com/ipython/ipython) from 7.34.0 to 8.10.0. - [Release notes](https://github.com/ipython/ipython/releases) - [Commits](https://github.com/ipython/ipython/compare/7.34.0...8.10.0) --- updated-dependencies: - dependency-name: ipython dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- poetry.lock | 70 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4bc78520..9c45f694 100644 --- a/poetry.lock +++ b/poetry.lock @@ -507,13 +507,13 @@ files = [ [[package]] name = "ipython" -version = "7.34.0" +version = "8.10.0" description = "IPython: Productive Interactive Computing" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "ipython-7.34.0-py3-none-any.whl", hash = "sha256:c175d2440a1caff76116eb719d40538fbb316e214eda85c5515c303aacbfb23e"}, - {file = "ipython-7.34.0.tar.gz", hash = "sha256:af3bdb46aa292bce5615b1b2ebc76c2080c5f77f54bda2ec72461317273e7cd6"}, + {file = "ipython-8.10.0-py3-none-any.whl", hash = "sha256:b38c31e8fc7eff642fc7c597061fff462537cf2314e3225a19c906b7b0d8a345"}, + {file = "ipython-8.10.0.tar.gz", hash = "sha256:b13a1d6c1f5818bd388db53b7107d17454129a70de2b87481d555daede5eb49e"}, ] [package.dependencies] @@ -525,21 +525,23 @@ jedi = ">=0.16" matplotlib-inline = "*" pexpect = {version = ">4.3", markers = "sys_platform != \"win32\""} pickleshare = "*" -prompt-toolkit = ">=2.0.0,<3.0.0 || >3.0.0,<3.0.1 || >3.0.1,<3.1.0" -pygments = "*" -setuptools = ">=18.5" -traitlets = ">=4.2" +prompt-toolkit = ">=3.0.30,<3.1.0" +pygments = ">=2.4.0" +stack-data = "*" +traitlets = ">=5" [package.extras] -all = ["Sphinx (>=1.3)", "ipykernel", "ipyparallel", "ipywidgets", "nbconvert", "nbformat", "nose (>=0.10.1)", "notebook", "numpy (>=1.17)", "pygments", "qtconsole", "requests", "testpath"] -doc = ["Sphinx (>=1.3)"] +all = ["black", "curio", "docrepr", "ipykernel", "ipyparallel", "ipywidgets", "matplotlib", "matplotlib (!=3.2.0)", "nbconvert", "nbformat", "notebook", "numpy (>=1.21)", "pandas", "pytest (<7)", "pytest (<7.1)", "pytest-asyncio", "qtconsole", "setuptools (>=18.5)", "sphinx (>=1.3)", "sphinx-rtd-theme", "stack-data", "testpath", "trio", "typing-extensions"] +black = ["black"] +doc = ["docrepr", "ipykernel", "matplotlib", "pytest (<7)", "pytest (<7.1)", "pytest-asyncio", "setuptools (>=18.5)", "sphinx (>=1.3)", "sphinx-rtd-theme", "stack-data", "testpath", "typing-extensions"] kernel = ["ipykernel"] nbconvert = ["nbconvert"] nbformat = ["nbformat"] notebook = ["ipywidgets", "notebook"] parallel = ["ipyparallel"] qtconsole = ["qtconsole"] -test = ["ipykernel", "nbformat", "nose (>=0.10.1)", "numpy (>=1.17)", "pygments", "requests", "testpath"] +test = ["pytest (<7.1)", "pytest-asyncio", "testpath"] +test-extra = ["curio", "matplotlib (!=3.2.0)", "nbformat", "numpy (>=1.21)", "pandas", "pytest (<7.1)", "pytest-asyncio", "testpath", "trio"] [[package]] name = "isort" @@ -935,13 +937,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "prompt-toolkit" -version = "3.0.26" +version = "3.0.38" description = "Library for building powerful interactive command lines in Python" optional = false -python-versions = ">=3.6.2" +python-versions = ">=3.7.0" files = [ - {file = "prompt_toolkit-3.0.26-py3-none-any.whl", hash = "sha256:4bcf119be2200c17ed0d518872ef922f1de336eb6d1ddbd1e089ceb6447d97c6"}, - {file = "prompt_toolkit-3.0.26.tar.gz", hash = "sha256:a51d41a6a45fd9def54365bca8f0402c8f182f2b6f7e29c74d55faeb9fb38ac4"}, + {file = "prompt_toolkit-3.0.38-py3-none-any.whl", hash = "sha256:45ea77a2f7c60418850331366c81cf6b5b9cf4c7fd34616f733c5427e6abbb1f"}, + {file = "prompt_toolkit-3.0.38.tar.gz", hash = "sha256:23ac5d50538a9a38c8bde05fecb47d0b403ecd0662857a86f886f798563d5b9b"}, ] [package.dependencies] @@ -978,6 +980,20 @@ urwid_readline = "*" [package.extras] completion = ["shtab"] +[[package]] +name = "pure-eval" +version = "0.2.2" +description = "Safely evaluate AST nodes without side effects" +optional = false +python-versions = "*" +files = [ + {file = "pure_eval-0.2.2-py3-none-any.whl", hash = "sha256:01eaab343580944bc56080ebe0a674b39ec44a945e6d09ba7db3cb8cec289350"}, + {file = "pure_eval-0.2.2.tar.gz", hash = "sha256:2b45320af6dfaa1750f543d714b6d1c520a1688dec6fd24d339063ce0aaa9ac3"}, +] + +[package.extras] +tests = ["pytest"] + [[package]] name = "pycodestyle" version = "2.7.0" @@ -1375,7 +1391,8 @@ files = [ {file = "ruamel.yaml.clib-0.2.7-cp310-cp310-win32.whl", hash = "sha256:763d65baa3b952479c4e972669f679fe490eee058d5aa85da483ebae2009d231"}, {file = "ruamel.yaml.clib-0.2.7-cp310-cp310-win_amd64.whl", hash = "sha256:d000f258cf42fec2b1bbf2863c61d7b8918d31ffee905da62dede869254d3b8a"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:045e0626baf1c52e5527bd5db361bc83180faaba2ff586e763d3d5982a876a9e"}, - {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_12_6_arm64.whl", hash = "sha256:721bc4ba4525f53f6a611ec0967bdcee61b31df5a56801281027a3a6d1c2daf5"}, + {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-macosx_13_0_arm64.whl", hash = "sha256:1a6391a7cabb7641c32517539ca42cf84b87b667bad38b78d4d42dd23e957c81"}, + {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-manylinux2014_aarch64.whl", hash = "sha256:9c7617df90c1365638916b98cdd9be833d31d337dbcd722485597b43c4a215bf"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:41d0f1fa4c6830176eef5b276af04c89320ea616655d01327d5ce65e50575c94"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-win32.whl", hash = "sha256:f6d3d39611ac2e4f62c3128a9eed45f19a6608670c5a2f4f07f24e8de3441d38"}, {file = "ruamel.yaml.clib-0.2.7-cp311-cp311-win_amd64.whl", hash = "sha256:da538167284de58a52109a9b89b8f6a53ff8437dd6dc26d33b57bf6699153122"}, @@ -1410,7 +1427,7 @@ files = [ name = "setuptools" version = "65.6.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "setuptools-65.6.3-py3-none-any.whl", hash = "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54"}, @@ -1643,6 +1660,25 @@ attrs = ">=19.2" certifi = "*" jsonschema = ">=3.0" +[[package]] +name = "stack-data" +version = "0.5.1" +description = "Extract data from python stack frames and tracebacks for informative displays" +optional = false +python-versions = "*" +files = [ + {file = "stack_data-0.5.1-py3-none-any.whl", hash = "sha256:5120731a18ba4c82cefcf84a945f6f3e62319ef413bfc210e32aca3a69310ba2"}, + {file = "stack_data-0.5.1.tar.gz", hash = "sha256:95eb784942e861a3d80efd549ff9af6cf847d88343a12eb681d7157cfcb6e32b"}, +] + +[package.dependencies] +asttokens = "*" +executing = "*" +pure-eval = "*" + +[package.extras] +tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"] + [[package]] name = "strenum" version = "0.4.10" From 24a1cc345bdf367cca531d6020f125e609b6c945 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 01:56:17 +0200 Subject: [PATCH 4/7] chore(deps): pre-commit autoupdate (#604) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.270 → v0.0.284](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.270...v0.0.284) - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) - [github.com/asottile/blacken-docs: 1.13.0 → 1.15.0](https://github.com/asottile/blacken-docs/compare/1.13.0...1.15.0) - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.1](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.9-for-vscode...v3.0.1) - [github.com/pre-commit/mirrors-mypy: v1.3.0 → v1.5.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.3.0...v1.5.0) - [github.com/commitizen-tools/commitizen: 3.2.2 → 3.6.0](https://github.com/commitizen-tools/commitizen/compare/3.2.2...3.6.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore: fix ruff warnings --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: W. Augusto Andreoli --- .pre-commit-config.yaml | 14 +++++++------- docs/autofix_docs.py | 4 +--- docs/conf.py | 5 +++-- pyproject.toml | 1 + src/nitpick/core.py | 14 +++++++++----- src/nitpick/plugins/base.py | 4 ++-- src/nitpick/plugins/info.py | 12 ++++++++---- src/nitpick/plugins/ini.py | 4 ++-- src/nitpick/plugins/json.py | 6 +++--- src/nitpick/plugins/text.py | 8 ++++---- src/nitpick/plugins/toml.py | 4 ++-- src/nitpick/plugins/yaml.py | 4 ++-- src/nitpick/project.py | 2 +- src/nitpick/schemas.py | 18 +++++++++++------- src/nitpick/style/config.py | 17 +++++++++++------ src/nitpick/style/core.py | 2 +- tasks.py | 8 +++++--- tests/test_builtin.py | 5 +++-- tests/test_meta.py | 4 ++-- 19 files changed, 78 insertions(+), 58 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ba22cbc..81dadd6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,8 +39,8 @@ repos: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.270 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.284 hooks: - id: ruff args: [--fix] @@ -50,12 +50,12 @@ repos: - id: sort-all language_version: python3.8 - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 + rev: 1.15.0 hooks: - id: blacken-docs additional_dependencies: [black==22.1.0] @@ -65,12 +65,12 @@ repos: - id: python-check-mock-methods - id: rst-backticks - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.9-for-vscode + rev: v3.0.1 hooks: - id: prettier stages: [commit] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.5.0 hooks: - id: mypy # https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-error-codes @@ -109,7 +109,7 @@ repos: # https://docs.openstack.org/bashate/latest/man/bashate.html#options args: [-i, E006] - repo: https://github.com/commitizen-tools/commitizen - rev: 3.2.2 + rev: 3.6.0 hooks: - id: commitizen stages: [commit-msg] diff --git a/docs/autofix_docs.py b/docs/autofix_docs.py index fde1f724..d21a6317 100644 --- a/docs/autofix_docs.py +++ b/docs/autofix_docs.py @@ -266,9 +266,7 @@ def rst_table(header: tuple[str, ...], rows: list[tuple[str, ...]]) -> list[str] def write_readme(file_types: set[FileType], divider: str) -> int: """Write the README.""" # TODO: chore: quickstart.rst has some parts of README.rst as a copy/paste/change - rows: list[tuple[str, ...]] = [] - for file_type in sorted(file_types): - rows.append(file_type.row) + rows: list[tuple[str, ...]] = [file_type.row for file_type in sorted(file_types)] lines = rst_table(("File type", "``nitpick check``", "``nitpick fix``"), rows) return DocFile("../README.rst").write(lines, divider) diff --git a/docs/conf.py b/docs/conf.py index 049e3773..b6c49988 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,8 +4,9 @@ full list see the documentation: http://www.sphinx-doc.org/en/master/config """ +from __future__ import annotations + import os -from typing import Dict # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, @@ -189,7 +190,7 @@ # -- Options for LaTeX output ------------------------------------------------ -latex_elements: Dict[str, str] = { +latex_elements: dict[str, str] = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', diff --git a/pyproject.toml b/pyproject.toml index b906cad7..d2188457 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,6 +136,7 @@ ignore = [ "E402", # Module level import not at top of file "E501", # Line too long "FBT", # https://beta.ruff.rs/docs/rules/#flake8-boolean-trap-fbt + "FIX002", # Line contains TO-DO, consider resolving the issue "TD002", # Missing author in TO DO "TD003", # Missing issue link on the line following this TO DO ] diff --git a/src/nitpick/core.py b/src/nitpick/core.py index adf6cfef..218715a7 100644 --- a/src/nitpick/core.py +++ b/src/nitpick/core.py @@ -1,9 +1,11 @@ """The Nitpick application.""" +from __future__ import annotations + import os from functools import lru_cache from itertools import chain from pathlib import Path -from typing import Iterator, List, Optional +from typing import TYPE_CHECKING, Iterator import click from loguru import logger @@ -12,9 +14,11 @@ from nitpick.generic import filter_names, relative_to_current_dir from nitpick.plugins.info import FileInfo from nitpick.project import Project -from nitpick.typedefs import PathOrStr from nitpick.violations import Fuss, ProjectViolations, Reporter +if TYPE_CHECKING: + from nitpick.typedefs import PathOrStr + class Nitpick: """The Nitpick API.""" @@ -32,14 +36,14 @@ def __init__(self) -> None: @classmethod @lru_cache - def singleton(cls) -> "Nitpick": + def singleton(cls) -> Nitpick: """Return a single instance of the class.""" Nitpick._allow_init = True instance = cls() Nitpick._allow_init = False return instance - def init(self, project_root: Optional[PathOrStr] = None, offline: Optional[bool] = None) -> "Nitpick": + def init(self, project_root: PathOrStr | None = None, offline: bool | None = None) -> Nitpick: """Initialize attributes of the singleton.""" self.project = Project(project_root) @@ -115,7 +119,7 @@ def enforce_style(self, *partial_names: str, autofix=True) -> Iterator[Fuss]: for plugin_class in self.project.plugin_manager.hook.can_handle(info=info): yield from plugin_class(info, config_dict, autofix).entry_point() - def configured_files(self, *partial_names: str) -> List[Path]: + def configured_files(self, *partial_names: str) -> list[Path]: """List of files configured in the Nitpick style. Filter only the selected partial names.""" return [Path(self.project.root) / key for key in filter_names(self.project.style_dict, *partial_names)] diff --git a/src/nitpick/plugins/base.py b/src/nitpick/plugins/base.py index e964ca32..0433b98f 100644 --- a/src/nitpick/plugins/base.py +++ b/src/nitpick/plugins/base.py @@ -3,7 +3,7 @@ import abc import fnmatch -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING, ClassVar, Iterator from autorepr import autotext from loguru import logger @@ -43,7 +43,7 @@ class NitpickPlugin(metaclass=abc.ABCMeta): # pylint: disable=too-many-instance validation_schema: Schema | None = None #: Which ``identify`` tags this :py:class:`nitpick.plugins.base.NitpickPlugin` child recognises. - identify_tags: set[str] = set() + identify_tags: ClassVar = set() skip_empty_suggestion = False diff --git a/src/nitpick/plugins/info.py b/src/nitpick/plugins/info.py index 14693c28..fbf7ee59 100644 --- a/src/nitpick/plugins/info.py +++ b/src/nitpick/plugins/info.py @@ -1,12 +1,16 @@ """Info needed by the plugins.""" +from __future__ import annotations + from dataclasses import dataclass, field -from typing import Set +from typing import TYPE_CHECKING from identify import identify from nitpick.constants import DOT from nitpick.exceptions import Deprecation -from nitpick.project import Project + +if TYPE_CHECKING: + from nitpick.project import Project @dataclass @@ -15,10 +19,10 @@ class FileInfo: project: Project path_from_root: str - tags: Set[str] = field(default_factory=set) + tags: set[str] = field(default_factory=set) @classmethod - def create(cls, project: Project, path_from_root: str) -> "FileInfo": + def create(cls, project: Project, path_from_root: str) -> FileInfo: """Clean the file name and get its tags.""" if Deprecation.pre_commit_without_dash(path_from_root): clean_path = DOT + path_from_root diff --git a/src/nitpick/plugins/ini.py b/src/nitpick/plugins/ini.py index ab822799..5f56a1de 100644 --- a/src/nitpick/plugins/ini.py +++ b/src/nitpick/plugins/ini.py @@ -3,7 +3,7 @@ from configparser import ConfigParser, DuplicateOptionError, Error, MissingSectionHeaderError, ParsingError from io import StringIO -from typing import TYPE_CHECKING, Any, Iterator +from typing import TYPE_CHECKING, Any, ClassVar, Iterator import dictdiffer from configupdater import ConfigUpdater, Space @@ -48,7 +48,7 @@ class IniPlugin(NitpickPlugin): """ fixable = True - identify_tags = {"ini", "editorconfig"} + identify_tags: ClassVar = {"ini", "editorconfig"} violation_base_code = 320 updater: ConfigUpdater diff --git a/src/nitpick/plugins/json.py b/src/nitpick/plugins/json.py index 393c5e77..b34e4d03 100644 --- a/src/nitpick/plugins/json.py +++ b/src/nitpick/plugins/json.py @@ -3,7 +3,7 @@ import json from itertools import chain -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING, ClassVar, Iterator from loguru import logger @@ -38,7 +38,7 @@ class JsonPlugin(NitpickPlugin): """ validation_schema = JsonFileSchema - identify_tags = {"json"} + identify_tags: ClassVar = {"json"} violation_base_code = 340 fixable = True @@ -74,7 +74,7 @@ def expected_dict_from_contains_json(self): for key, json_string in (self.expected_config.get(KEY_CONTAINS_JSON) or {}).items(): try: expected_config[key] = json.loads(json_string) - except json.JSONDecodeError as err: + except json.JSONDecodeError as err: # noqa: PERF203 # This should not happen, because the style was already validated before. # Maybe the NIP??? code was disabled by the user? logger.error(f"{err} on {KEY_CONTAINS_JSON} while checking {self.file_path}") diff --git a/src/nitpick/plugins/text.py b/src/nitpick/plugins/text.py index 9fea6b35..501e3691 100644 --- a/src/nitpick/plugins/text.py +++ b/src/nitpick/plugins/text.py @@ -1,7 +1,7 @@ """Text files.""" from __future__ import annotations -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING, ClassVar, Iterator from marshmallow import Schema from marshmallow.orderedset import OrderedSet @@ -22,14 +22,14 @@ class TextItemSchema(Schema): """Validation schema for the object inside ``contains``.""" - error_messages = {"unknown": help_message("Unknown configuration", TEXT_FILE_RTFD_PAGE)} + error_messages = {"unknown": help_message("Unknown configuration", TEXT_FILE_RTFD_PAGE)} # noqa: RUF012 line = fields.NonEmptyString() class TextSchema(Schema): """Validation schema for the text file TOML configuration.""" - error_messages = {"unknown": help_message("Unknown configuration", TEXT_FILE_RTFD_PAGE)} + error_messages = {"unknown": help_message("Unknown configuration", TEXT_FILE_RTFD_PAGE)} # noqa: RUF012 contains = fields.List(fields.Nested(TextItemSchema)) @@ -53,7 +53,7 @@ class TextPlugin(NitpickPlugin): line = "def" """ - identify_tags = {"text"} + identify_tags: ClassVar = {"text"} validation_schema = TextSchema #: All other files are also text files, and they already have a suggested content message diff --git a/src/nitpick/plugins/toml.py b/src/nitpick/plugins/toml.py index 4c88d759..c137f46d 100644 --- a/src/nitpick/plugins/toml.py +++ b/src/nitpick/plugins/toml.py @@ -2,7 +2,7 @@ from __future__ import annotations from itertools import chain -from typing import TYPE_CHECKING, Iterator, cast +from typing import TYPE_CHECKING, ClassVar, Iterator, cast from tomlkit import dumps, parse @@ -29,7 +29,7 @@ class TomlPlugin(NitpickPlugin): There are :ref:`many other examples here `. """ - identify_tags = {"toml"} + identify_tags: ClassVar = {"toml"} violation_base_code = 310 fixable = True diff --git a/src/nitpick/plugins/yaml.py b/src/nitpick/plugins/yaml.py index 2b2fed8f..01815fee 100644 --- a/src/nitpick/plugins/yaml.py +++ b/src/nitpick/plugins/yaml.py @@ -2,7 +2,7 @@ from __future__ import annotations from itertools import chain -from typing import TYPE_CHECKING, Iterator, cast +from typing import TYPE_CHECKING, ClassVar, Iterator, cast from nitpick.blender import Comparison, YamlDoc, traverse_yaml_tree from nitpick.config import SpecialConfig @@ -47,7 +47,7 @@ class YamlPlugin(NitpickPlugin): Nitpick will not validate hooks and missing keys as it did before; it's not the purpose of this package. """ - identify_tags = {"yaml"} + identify_tags: ClassVar = {"yaml"} violation_base_code = 360 fixable = True diff --git a/src/nitpick/project.py b/src/nitpick/project.py index 9aa773e7..837f31b7 100644 --- a/src/nitpick/project.py +++ b/src/nitpick/project.py @@ -90,7 +90,7 @@ def find_main_python_file(root_dir: Path) -> Path: class ToolNitpickSectionSchema(BaseNitpickSchema): """Validation schema for the ``[tool.nitpick]`` section on ``pyproject.toml``.""" - error_messages = {"unknown": help_message("Unknown configuration", "configuration.html")} + error_messages = {"unknown": help_message("Unknown configuration", "configuration.html")} # noqa: RUF012 style = PolyField(deserialization_schema_selector=fields.string_or_list_field) cache = fields.NonEmptyString() diff --git a/src/nitpick/schemas.py b/src/nitpick/schemas.py index 4b6694f9..9cf60c89 100644 --- a/src/nitpick/schemas.py +++ b/src/nitpick/schemas.py @@ -1,5 +1,5 @@ """Marshmallow schemas.""" -from typing import Dict +from __future__ import annotations from marshmallow import Schema from marshmallow_polyfield import PolyField @@ -10,7 +10,7 @@ from nitpick.constants import READ_THE_DOCS_URL, SETUP_CFG -def flatten_marshmallow_errors(errors: Dict) -> str: +def flatten_marshmallow_errors(errors: dict) -> str: """Flatten Marshmallow errors to a string.""" formatted = [] for field, data in SortedDict(flatten_quotes(errors)).items(): @@ -32,13 +32,15 @@ def help_message(sentence: str, help_page: str) -> str: class BaseNitpickSchema(Schema): """Base schema for all others, with default error messages.""" - error_messages = {"unknown": help_message("Unknown configuration", "nitpick_section.html")} + error_messages = {"unknown": help_message("Unknown configuration", "nitpick_section.html")} # noqa: RUF012 class NitpickStylesSectionSchema(BaseNitpickSchema): """Validation schema for the ``[nitpick.styles]`` section on the style file.""" - error_messages = {"unknown": help_message("Unknown configuration", "nitpick_section.html#nitpick-styles")} + error_messages = { # noqa: RUF012 + "unknown": help_message("Unknown configuration", "nitpick_section.html#nitpick-styles") + } include = PolyField(deserialization_schema_selector=fields.string_or_list_field) @@ -46,7 +48,9 @@ class NitpickStylesSectionSchema(BaseNitpickSchema): class IniSchema(BaseNitpickSchema): """Validation schema for INI files.""" - error_messages = {"unknown": help_message("Unknown configuration", "nitpick_section.html#comma-separated-values")} + error_messages = { # noqa: RUF012 + "unknown": help_message("Unknown configuration", "nitpick_section.html#comma-separated-values") + } comma_separated_values = fields.List(fields.String(validate=fields.validate_section_dot_field)) @@ -54,7 +58,7 @@ class IniSchema(BaseNitpickSchema): class NitpickFilesSectionSchema(BaseNitpickSchema): """Validation schema for the ``[nitpick.files]`` section on the style file.""" - error_messages = {"unknown": help_message("Unknown file", "nitpick_section.html#nitpick-files")} + error_messages = {"unknown": help_message("Unknown file", "nitpick_section.html#nitpick-files")} # noqa: RUF012 absent = fields.Dict(fields.NonEmptyString, fields.String()) present = fields.Dict(fields.NonEmptyString, fields.String()) @@ -81,6 +85,6 @@ class NitpickSectionSchema(BaseNitpickSchema): class BaseStyleSchema(Schema): """Base validation schema for style files. Dynamic fields will be added to it later.""" - error_messages = {"unknown": help_message("Unknown file", "plugins.html")} + error_messages = {"unknown": help_message("Unknown file", "plugins.html")} # noqa: RUF012 nitpick = fields.Nested(NitpickSectionSchema) diff --git a/src/nitpick/style/config.py b/src/nitpick/style/config.py index 0cb94ba1..88f79e92 100644 --- a/src/nitpick/style/config.py +++ b/src/nitpick/style/config.py @@ -1,16 +1,21 @@ """Config validator.""" +from __future__ import annotations + from dataclasses import dataclass -from typing import Dict, List, Tuple, Type +from typing import TYPE_CHECKING -from marshmallow import Schema from more_itertools import peekable from nitpick.constants import PROJECT_NAME from nitpick.exceptions import Deprecation from nitpick.plugins.info import FileInfo -from nitpick.project import Project from nitpick.schemas import BaseStyleSchema, NitpickSectionSchema -from nitpick.typedefs import JsonDict + +if TYPE_CHECKING: + from marshmallow import Schema + + from nitpick.project import Project + from nitpick.typedefs import JsonDict @dataclass(repr=True) # TODO: refactor: use attrs instead @@ -19,7 +24,7 @@ class ConfigValidator: project: Project - def validate(self, config_dict: Dict) -> Tuple[Dict, Dict]: + def validate(self, config_dict: dict) -> tuple[dict, dict]: """Validate an already parsed toml file.""" validation_errors = {} toml_dict = {} @@ -61,7 +66,7 @@ def _validate_schemas(self, info, schemas, value_dict): return False, all_errors @staticmethod - def _validate_schema(schema: Type[Schema], path_from_root: str, original_data: JsonDict) -> Dict[str, List[str]]: + def _validate_schema(schema: type[Schema], path_from_root: str, original_data: JsonDict) -> dict[str, list[str]]: """Validate the schema for the file.""" if not schema: return {} diff --git a/src/nitpick/style/core.py b/src/nitpick/style/core.py index aee324b0..01d242d3 100644 --- a/src/nitpick/style/core.py +++ b/src/nitpick/style/core.py @@ -196,7 +196,7 @@ def merge_toml_dict(self) -> JsonDict: try: merged_style_path.write_text(toml.reformatted) break - except OSError: + except OSError: # noqa: PERF203 attempt += 1 return merged_dict diff --git a/tasks.py b/tasks.py index bf2a9613..53bc9e2b 100644 --- a/tasks.py +++ b/tasks.py @@ -4,9 +4,11 @@ - https://www.pyinvoke.org/ - https://docs.pyinvoke.org/en/stable/api/runners.html#invoke.runners.Runner.run """ +from __future__ import annotations + import sys from configparser import ConfigParser -from typing import Iterator, List +from typing import Iterator from invoke import Collection, Exit, task # pylint: disable=import-error @@ -77,12 +79,12 @@ def config(c) -> str: return "" temp_tox_ini = ".temp-tox.ini" - # Hack to be able to run `invoke lint` on a macOS machine during development. + # Trick to be able to run `invoke lint` on a macOS machine during development. c.run(f"sed 's/platform = linux/platform = darwin/g' tox.ini > {temp_tox_ini}") return f"-c {temp_tox_ini}" @property - def python_versions(self) -> List[str]: + def python_versions(self) -> list[str]: """Python versions executed in tox.""" versions = [] for py_plus_version_without_dot in self._parser["tox"]["envlist"].split(","): diff --git a/tests/test_builtin.py b/tests/test_builtin.py index 65fae340..5dc598df 100644 --- a/tests/test_builtin.py +++ b/tests/test_builtin.py @@ -1,6 +1,7 @@ """Test built-in styles shipped as resources under the ``nitpick.resources`` module.""" +from __future__ import annotations + from pathlib import Path -from typing import Dict, List import pytest from identify.identify import ALL_TAGS @@ -32,7 +33,7 @@ EDITOR_CONFIG: 321, PACKAGE_JSON: 341, } -BUILTIN_STYLE_EXTRA_VIOLATIONS: Dict[str, List[Fuss]] = { +BUILTIN_STYLE_EXTRA_VIOLATIONS: dict[str, list[Fuss]] = { "any/pre-commit-hooks": [ Fuss( False, diff --git a/tests/test_meta.py b/tests/test_meta.py index 3fc232c2..72e2fdf8 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -22,11 +22,11 @@ def test_bumpversion_files_match_package_json(): package_json = Path(REPO_ROOT / PACKAGE_JSON) package_json_dict = json.loads(package_json.read_text()) package_json_git_files = set( - [ + next( obj[1]["assets"] for obj in package_json_dict["release"]["plugins"] if isinstance(obj, list) and "/git" in obj[0] - ][0] + ) ) package_json_git_files.remove(".bumpversion.cfg") From 5d23b6c8be4e7bc6e5e1eb0ea0b95dcd17948e23 Mon Sep 17 00:00:00 2001 From: Dany Gielow Date: Sat, 19 Aug 2023 03:11:17 +0200 Subject: [PATCH 5/7] feat: accept all types of GitHub tokens (personal and apps) (#603) --- src/nitpick/style/fetchers/github.py | 12 ++++-------- tests/test_style.py | 29 +++++++++++++--------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/nitpick/style/fetchers/github.py b/src/nitpick/style/fetchers/github.py index 068dedf9..4cb0cc57 100644 --- a/src/nitpick/style/fetchers/github.py +++ b/src/nitpick/style/fetchers/github.py @@ -50,14 +50,10 @@ def token(self) -> str | None: return token @property - def credentials(self) -> tuple[str, str] | tuple[()]: - """Credentials encoded in this URL. - - A tuple of ``(api_token, '')`` if present, or empty tuple otherwise. - - """ + def authorization_header(self) -> dict[str, str] | None: + """Authorization header encoded in this URL.""" token = self.token - return (token, "") if token else () + return {"Authorization": f"token {token}"} if token else None @property def git_reference_or_default(self) -> str: @@ -166,5 +162,5 @@ def _normalize_scheme(self, scheme: str) -> str: # pylint: disable=no-self-use def _download(self, url: furl, **kwargs) -> str: github_url = GitHubURL.from_furl(url) - kwargs.setdefault("auth", github_url.credentials) + kwargs.setdefault("headers", github_url.authorization_header) return super()._download(github_url.raw_content_url, **kwargs) diff --git a/tests/test_style.py b/tests/test_style.py index a9bb1993..36ea501a 100644 --- a/tests/test_style.py +++ b/tests/test_style.py @@ -1,6 +1,5 @@ """Style tests.""" import warnings -from base64 import b64encode from pathlib import Path from textwrap import dedent from unittest import mock @@ -426,8 +425,7 @@ def test_fetch_private_github_urls(tmp_path): missing = "thing"{SUGGESTION_END} """ ) - token_on_basic_auth = b64encode(f"{file_token}:".encode()).decode().strip() - assert responses.calls[0].request.headers["Authorization"] == f"Basic {token_on_basic_auth}" + assert responses.calls[0].request.headers["Authorization"] == f"token {file_token}" project.flake8(offline=True).assert_no_errors() @@ -460,8 +458,7 @@ def test_fetch_private_github_urls_no_branch(tmp_path): """ ) assert responses.calls[0].request.headers["Authorization"] == f"token {file_token}" - token_on_basic_auth = b64encode(f"{file_token}:".encode()).decode().strip() - assert responses.calls[1].request.headers["Authorization"] == f"Basic {token_on_basic_auth}" + assert responses.calls[1].request.headers["Authorization"] == f"token {file_token}" project.flake8(offline=True).assert_no_errors() @@ -480,10 +477,10 @@ def test_fetch_private_github_urls_no_branch(tmp_path): "https://raw.githubusercontent.com/andreoliwa/nitpick/develop/initial.toml", ], ) -def test_github_url_without_token_has_no_credentials(style_url): +def test_github_url_without_token_has_no_authorization_header(style_url): """Check private GitHub URLs with a token in various places are parsed correctly.""" parsed = GitHubURL.from_furl(furl(style_url)) - assert parsed.credentials == () + assert parsed.authorization_header is None @pytest.mark.parametrize( @@ -501,10 +498,10 @@ def test_github_url_without_token_has_no_credentials(style_url): "https://token@raw.githubusercontent.com/andreoliwa/nitpick/develop/initial.toml", ], ) -def test_github_url_with_fixed_userinfo_token_has_correct_credential(url): +def test_github_url_with_fixed_userinfo_token_has_correct_authorization_header(url): """Check private GitHub URLs with a token in various places are parsed correctly.""" parsed = GitHubURL.from_furl(furl(url)) - assert parsed.credentials == ("token", "") + assert parsed.authorization_header == {"Authorization": "token token"} @pytest.mark.parametrize( @@ -522,11 +519,11 @@ def test_github_url_with_fixed_userinfo_token_has_correct_credential(url): "https://$TOKEN@raw.githubusercontent.com/andreoliwa/nitpick/develop/initial.toml", ], ) -def test_github_url_with_variable_userinfo_token_has_correct_credential(url, monkeypatch): +def test_github_url_with_variable_userinfo_token_has_correct_authorization_header(url, monkeypatch): """Check private GitHub URLs with a token in various places are parsed correctly.""" monkeypatch.setenv("TOKEN", "envvar-token") parsed = GitHubURL.from_furl(furl(url)) - assert parsed.credentials == ("envvar-token", "") + assert parsed.authorization_header == {"Authorization": "token envvar-token"} @pytest.mark.parametrize( @@ -546,18 +543,18 @@ def test_github_url_with_variable_userinfo_token_has_correct_credential(url, mon "github://$ENVVAR@andreoliwa/nitpick/initial.toml?token=$NOTUSED", ], ) -def test_github_url_with_variable_query_token_has_correct_credential(url, monkeypatch): +def test_github_url_with_variable_query_token_has_correct_authorization_header(url, monkeypatch): """Check private GitHub URLs with a token in various places are parsed correctly.""" monkeypatch.setenv("ENVVAR", "envvar-token") parsed = GitHubURL.from_furl(furl(url)) - assert parsed.credentials == ("envvar-token", "") + assert parsed.authorization_header == {"Authorization": "token envvar-token"} -def test_github_url_with_missing_envvar_has_empty_credential(monkeypatch): +def test_github_url_with_missing_envvar_has_empty_authorization_header(monkeypatch): """Environment var that doesn't exist is replaced with empty string.""" monkeypatch.delenv("MISSINGVAR", raising=False) parsed = GitHubURL.from_furl(furl("https://github.com/foo/bar/blob/branch/filename.toml?token=$MISSINGVAR")) - assert parsed.credentials == () + assert parsed.authorization_header is None def test_github_url_query_token_retains_other_queryparams(): @@ -567,7 +564,7 @@ def test_github_url_query_token_retains_other_queryparams(): parsed = GitHubURL.from_furl( furl("https://github.com/foo/bar/blob/branch/filename.toml?token=somevar&leavemealone=ok") ) - assert parsed.credentials == ("somevar", "") + assert parsed.authorization_header == {"Authorization": "token somevar"} assert ("leavemealone", "ok") in parsed.url.query.params.items() From 8113eb6b3aef5e73d1422d68162aaf6e5ff0f2f6 Mon Sep 17 00:00:00 2001 From: "W. Augusto Andreoli" Date: Sat, 19 Aug 2023 03:35:13 +0200 Subject: [PATCH 6/7] ci: always run build and release on master branch --- .github/workflows/python.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 7cdc81f3..6142a66b 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -24,7 +24,8 @@ jobs: build: needs: pre_job - if: needs.pre_job.outputs.should_skip != 'true' + # Always run the build step when pushing to master + if: needs.pre_job.outputs.should_skip != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/master') name: "${{ matrix.python-version }} ${{ matrix.os }}" strategy: fail-fast: false From 309379e91e14595a3811d80502b164a91d47d717 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 19 Aug 2023 01:46:35 +0000 Subject: [PATCH 7/7] chore(release): 0.34.0 [skip ci] # [0.34.0](https://github.com/andreoliwa/nitpick/compare/v0.33.2...v0.34.0) (2023-08-19) ### Features * accept all types of GitHub tokens (personal and apps) ([#603](https://github.com/andreoliwa/nitpick/issues/603)) ([5d23b6c](https://github.com/andreoliwa/nitpick/commit/5d23b6c8be4e7bc6e5e1eb0ea0b95dcd17948e23)) * drop support for Python 3.7 ([65178f3](https://github.com/andreoliwa/nitpick/commit/65178f3e4f1ba997306ff8b3405111e37978bd3f)) --- .bumpversion.cfg | 2 +- CHANGELOG.md | 7 +++++++ README.rst | 4 ++-- docs/conf.py | 2 +- docs/configuration.rst | 8 ++++---- docs/quickstart.rst | 4 ++-- .../nitpick.megalinter-descriptor.yml | 2 +- nitpick-style.toml | 2 +- package.json | 2 +- pyproject.toml | 2 +- src/nitpick/__init__.py | 2 +- 11 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c894e2ea..6644ceb4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.33.2 +current_version = 0.34.0 commit = False tag = False diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a61dcb..26098936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.34.0](https://github.com/andreoliwa/nitpick/compare/v0.33.2...v0.34.0) (2023-08-19) + +### Features + +- accept all types of GitHub tokens (personal and apps) ([#603](https://github.com/andreoliwa/nitpick/issues/603)) ([5d23b6c](https://github.com/andreoliwa/nitpick/commit/5d23b6c8be4e7bc6e5e1eb0ea0b95dcd17948e23)) +- drop support for Python 3.7 ([65178f3](https://github.com/andreoliwa/nitpick/commit/65178f3e4f1ba997306ff8b3405111e37978bd3f)) + ## [0.33.2](https://github.com/andreoliwa/nitpick/compare/v0.33.1...v0.33.2) (2023-05-29) ### Bug Fixes diff --git a/README.rst b/README.rst index cba604f1..6d30ac96 100644 --- a/README.rst +++ b/README.rst @@ -375,7 +375,7 @@ this to the ``.pre-commit-config.yaml`` in your repository:: repos: - repo: https://github.com/andreoliwa/nitpick - rev: v0.33.2 + rev: v0.34.0 hooks: - id: nitpick @@ -401,7 +401,7 @@ If you use `MegaLinter `_ you can run Nitpick as .. code-block:: yaml PLUGINS: - - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.33.2/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml + - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.34.0/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml ENABLE_LINTERS: - NITPICK diff --git a/docs/conf.py b/docs/conf.py index b6c49988..26489e58 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,7 +19,7 @@ author = "W. Augusto Andreoli" # The short X.Y version -version = "0.33.2" +version = "0.34.0" # The full version, including alpha/beta/rc tags release = version diff --git a/docs/configuration.rst b/docs/configuration.rst index 8919d22e..4f39c681 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -47,9 +47,9 @@ GitHub URL scheme (``github://`` or ``gh://``) pinned to a specific version: .. code-block:: toml [tool.nitpick] - style = "github://andreoliwa/nitpick@v0.33.2/nitpick-style.toml" + style = "github://andreoliwa/nitpick@v0.34.0/nitpick-style.toml" # or - style = "gh://andreoliwa/nitpick@v0.33.2/nitpick-style.toml" + style = "gh://andreoliwa/nitpick@v0.34.0/nitpick-style.toml" The ``@`` syntax is used to get a Git reference (commit, tag, branch). It is similar to the syntax used by ``pip`` and ``pipx``: @@ -76,14 +76,14 @@ A regular GitHub URL also works. The corresponding raw URL will be used. .. code-block:: toml [tool.nitpick] - style = "https://github.com/andreoliwa/nitpick/blob/v0.33.2/nitpick-style.toml" + style = "https://github.com/andreoliwa/nitpick/blob/v0.34.0/nitpick-style.toml" Or use the raw GitHub URL directly: .. code-block:: toml [tool.nitpick] - style = "https://raw.githubusercontent.com/andreoliwa/nitpick/v0.33.2/nitpick-style.toml" + style = "https://raw.githubusercontent.com/andreoliwa/nitpick/v0.34.0/nitpick-style.toml" You can also use the raw URL of a `GitHub Gist `_: diff --git a/docs/quickstart.rst b/docs/quickstart.rst index ecf8de18..14907c33 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -61,7 +61,7 @@ If you use pre-commit_ on your project, add this to the ``.pre-commit-config.yam repos: - repo: https://github.com/andreoliwa/nitpick - rev: v0.33.2 + rev: v0.34.0 hooks: - id: nitpick @@ -100,7 +100,7 @@ If you use `MegaLinter `_ you can run Nitpick as .. code-block:: yaml PLUGINS: - - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.33.2/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml + - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.34.0/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml ENABLE_LINTERS: - NITPICK diff --git a/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml b/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml index 0630b1e1..390a5dfc 100644 --- a/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml +++ b/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml @@ -13,7 +13,7 @@ linters: name: NITPICK install: dockerfile: - - RUN pip install nitpick==0.33.2 + - RUN pip install nitpick==0.34.0 examples: - "nitpick check" - "nitpick fix" diff --git a/nitpick-style.toml b/nitpick-style.toml index dabace6e..57c5c28a 100644 --- a/nitpick-style.toml +++ b/nitpick-style.toml @@ -1,5 +1,5 @@ # Default style file for nitpick -# https://github.com/andreoliwa/nitpick/blob/v0.33.2/nitpick-style.toml +# https://github.com/andreoliwa/nitpick/blob/v0.34.0/nitpick-style.toml # Kept here for compatibility, if someone is still accessing the file via GitHub URL. # This style just includes the built-in preset shipped with Nitpick. diff --git a/package.json b/package.json index da97ba4b..af60c16e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nitpick", - "version": "0.33.2", + "version": "0.34.0", "repository": { "type": "git", "url": "https://github.com/andreoliwa/nitpick.git" diff --git a/pyproject.toml b/pyproject.toml index d2188457..aa95e6dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ line-length = 120 [tool.poetry] name = "nitpick" -version = "0.33.2" +version = "0.34.0" description = "Enforce the same settings across multiple language-independent projects" authors = ["W. Augusto Andreoli "] license = "MIT" diff --git a/src/nitpick/__init__.py b/src/nitpick/__init__.py index ca5f54b1..0b6e8912 100644 --- a/src/nitpick/__init__.py +++ b/src/nitpick/__init__.py @@ -5,6 +5,6 @@ from nitpick.core import Nitpick __all__ = ("Nitpick",) -__version__ = "0.33.2" +__version__ = "0.34.0" logger.disable(PROJECT_NAME)