From eef6f6f4f54537300343034f97e24ed24760ca0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 12:18:41 +0000 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#869) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> --- .github/workflows/docs.yml | 2 +- .github/workflows/tox.yml | 2 +- .pre-commit-config.yaml | 16 ++++++++-------- nbqa/__main__.py | 2 +- nbqa/handle_magics.py | 8 ++++---- setup.cfg | 2 +- tests/conftest.py | 15 +++------------ tests/tools/test_doctest.py | 4 ++++ tests/tools/test_pylint_works.py | 2 +- 9 files changed, 24 insertions(+), 29 deletions(-) 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: 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 }} 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$ 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/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" 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 = diff --git a/tests/conftest.py b/tests/conftest.py index 27d46442..c1611701 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,17 +2,8 @@ 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 shutil import copytree # pylint: disable=E0611,W4901 from typing import TYPE_CHECKING, Iterator import pytest @@ -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), dirs_exist_ok=True) @pytest.fixture 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 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] )