From 1173034f8afab9a5454596f4a2c30be6c76b7390 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:59:30 +0000 Subject: [PATCH 01/10] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/pre-commit/pre-commit: v3.8.0 → v4.0.1](https://github.com/pre-commit/pre-commit/compare/v3.8.0...v4.0.1) - [github.com/hauntsaninja/black-pre-commit-mirror: 24.8.0 → 24.10.0](https://github.com/hauntsaninja/black-pre-commit-mirror/compare/24.8.0...24.10.0) - [github.com/PyCQA/pylint: v3.2.7 → v3.3.1](https://github.com/PyCQA/pylint/compare/v3.2.7...v3.3.1) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.13.0) - [github.com/asottile/pyupgrade: v3.17.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.19.0) - [github.com/asottile/setup-cfg-fmt: v2.5.0 → v2.7.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.5.0...v2.7.0) - [github.com/kynan/nbstripout: 0.7.1 → 0.8.0](https://github.com/kynan/nbstripout/compare/0.7.1...0.8.0) --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ec2d017..6b9a4501 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer exclude: ^tests/data/ @@ -8,16 +8,16 @@ repos: - id: trailing-whitespace - id: debug-statements - repo: https://github.com/pre-commit/pre-commit - rev: v3.8.0 + rev: v4.0.1 hooks: - id: validate_manifest - repo: https://github.com/hauntsaninja/black-pre-commit-mirror # black compiled with mypyc - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/PyCQA/pylint - rev: v3.2.7 + rev: v3.3.1 hooks: - id: pylint files: ^(nbqa|tests)/ @@ -38,13 +38,13 @@ repos: - id: pydocstyle files: ^nbqa/ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy exclude: ^docs/ additional_dependencies: [types-setuptools, types-toml] - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -68,7 +68,7 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 + rev: v2.7.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/PyCQA/autoflake @@ -81,7 +81,7 @@ repos: - id: check-hooks-apply - id: check-useless-excludes - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 + rev: 0.8.0 hooks: - id: nbstripout exclude: ^tests/data/(databricks_notebook|notebook_for_testing)\.ipynb$ From 4ade1521cb96e5cf3d3c8ede470d9854b5edc289 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:00:22 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 28edc053..f7be9f59 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ install_requires = ipython>=7.8.0 tokenize-rt>=3.2.0 tomli -python_requires = >=3.8.0 +python_requires = >=3.9 [options.packages.find] exclude = From 3e056d58ff4c868265103cbfa07b818142f317b3 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:26:16 +0000 Subject: [PATCH 03/10] remove py38 --- .github/workflows/tox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 9ec7aee8..9c0085ed 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -9,7 +9,7 @@ jobs: tox: strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.12", "3.13"] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} From 5bc10509fb20d424d2ac380ae7cd83b541dcf2a7 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:27:55 +0000 Subject: [PATCH 04/10] try fixup docs --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a514df6c..b6028101 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: 3.8 # Same as RTD + python-version: 3.12 # Same as RTD - name: Cache multiple paths uses: actions/cache@v4 with: From 10a354b46de2549846ed3a443ac476a5b457627a Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:31:52 +0000 Subject: [PATCH 05/10] fixup --- tests/conftest.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 27d46442..72b2767f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,20 +2,11 @@ import shutil import sys -import warnings - -# distutils is deprecated, but this is just a test, so not urgent to update -with warnings.catch_warnings(): - warnings.filterwarnings( - "ignore", - message=r"The distutils package", - category=DeprecationWarning, - ) - from distutils.dir_util import copy_tree # pylint: disable=E0611,W4901 from pathlib import Path from typing import TYPE_CHECKING, Iterator import pytest +from shutils import copytree # pylint: disable=E0611,W4901 if TYPE_CHECKING: from py._path.local import LocalPath @@ -140,9 +131,9 @@ def tmp_test_data(tmpdir: "LocalPath") -> Iterator[Path]: """ dirname = Path("tests/data") temp_dir = Path(tmpdir) - copy_tree(str(dirname), str(temp_dir / dirname)) + copytree(str(dirname), str(temp_dir / dirname)) yield dirname - copy_tree(str(temp_dir / dirname), str(dirname)) + copytree(str(temp_dir / dirname), str(dirname)) @pytest.fixture From 41ddf53b885b081341af4e6ac8d27c522b588200 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:33:36 +0000 Subject: [PATCH 06/10] fixup --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 72b2767f..377096c8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,10 +3,10 @@ import shutil import sys from pathlib import Path +from shutil import copytree # pylint: disable=E0611,W4901 from typing import TYPE_CHECKING, Iterator import pytest -from shutils import copytree # pylint: disable=E0611,W4901 if TYPE_CHECKING: from py._path.local import LocalPath From 234638da97d42621fafb684f714add7680fe5ea5 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:43:45 +0000 Subject: [PATCH 07/10] fixup --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 377096c8..c1611701 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -133,7 +133,7 @@ def tmp_test_data(tmpdir: "LocalPath") -> Iterator[Path]: temp_dir = Path(tmpdir) copytree(str(dirname), str(temp_dir / dirname)) yield dirname - copytree(str(temp_dir / dirname), str(dirname)) + copytree(str(temp_dir / dirname), str(dirname), dirs_exist_ok=True) @pytest.fixture From fc2aecd3b6c713855b5def7b26aaf7d793140ad8 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:53:12 +0000 Subject: [PATCH 08/10] fix --- nbqa/handle_magics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nbqa/handle_magics.py b/nbqa/handle_magics.py index 9541d62e..dfe6caeb 100644 --- a/nbqa/handle_magics.py +++ b/nbqa/handle_magics.py @@ -29,8 +29,8 @@ def _get_node_args(func: ast.Call) -> List[str]: """ args = [] for arg in func.args: - if isinstance(arg, ast.Str): - args.append(arg.s) + if isinstance(arg, ast.Constant): + args.append(arg.value) else: raise AssertionError( "Please report a bug at https://github.com/nbQA-dev/nbQA/issues" @@ -158,8 +158,8 @@ def visit_Call(self, node: ast.Call) -> None: if node.func.attr == "run_cell_magic": args = [] for arg in node.args: - if isinstance(arg, ast.Str): - args.append(arg.s) + if isinstance(arg, ast.Constant): + args.append(arg.value) else: raise AssertionError( "Please report a bug at https://github.com/nbQA-dev/nbQA/issues" From 184462819c11282b82fe7298714756fc847c0251 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:54:56 +0000 Subject: [PATCH 09/10] fix --- nbqa/__main__.py | 2 +- tests/tools/test_pylint_works.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nbqa/__main__.py b/nbqa/__main__.py index bcafbcbc..087eb1d3 100644 --- a/nbqa/__main__.py +++ b/nbqa/__main__.py @@ -672,7 +672,7 @@ def _save_markdown_sources( SAVE_SOURCES = {False: _save_code_sources, True: _save_markdown_sources} -def _post_process_notebooks( # pylint: disable=R0913 +def _post_process_notebooks( # pylint: disable=R0913,R0917 saved_sources: SavedSources, nb_to_py_mapping: Mapping[str, TemporaryFile], mutated: bool, diff --git a/tests/tools/test_pylint_works.py b/tests/tools/test_pylint_works.py index 2c0d5748..9aec6448 100644 --- a/tests/tools/test_pylint_works.py +++ b/tests/tools/test_pylint_works.py @@ -54,5 +54,5 @@ def test_pylint_works(capsys: "CaptureFixture") -> None: horizontal_bar = "-----------------------------------" assert ( out.replace("\r\n", "\n").split(horizontal_bar)[0] - == expected_out.split(horizontal_bar)[0] + == expected_out.split(horizontal_bar, maxsplit=1)[0] ) From 24e9b000504042058d86d5890860b7d62858c1e8 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sun, 10 Nov 2024 12:15:09 +0000 Subject: [PATCH 10/10] py3.13 compat --- tests/tools/test_doctest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/tools/test_doctest.py b/tests/tools/test_doctest.py index 40ea1834..547e75e6 100644 --- a/tests/tools/test_doctest.py +++ b/tests/tools/test_doctest.py @@ -1,6 +1,7 @@ """Check that running :code:`doctest` works.""" import os +import sys from typing import TYPE_CHECKING from nbqa.__main__ import main @@ -51,6 +52,9 @@ def test_doctest_works(capsys: "CaptureFixture") -> None: " 1 of 2 in notebook_for_testing_copy.hello\n" "***Test Failed*** 1 failures.\n" ) + if sys.version_info >= (3, 13): + expected_out = expected_out.replace("1 failures", "1 failure") + expected_out = expected_out.replace("1 items", "1 item") try: assert out.replace("\r\n", "\n") == expected_out