Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#832)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/pre-commit/pre-commit: v3.4.0 → v3.5.0](pre-commit/pre-commit@v3.4.0...v3.5.0)
- [github.com/psf/black: 23.9.1 → 23.11.0](psf/black@23.9.1...23.11.0)
- [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](pre-commit/mirrors-prettier@v3.0.3...v3.1.0)
- [github.com/PyCQA/pylint: v3.0.0a7 → v3.0.1](pylint-dev/pylint@v3.0.0a7...v3.0.1)
- [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.7.0](pre-commit/mirrors-mypy@v1.5.1...v1.7.0)
- [github.com/asottile/pyupgrade: v3.13.0 → v3.15.0](asottile/pyupgrade@v3.13.0...v3.15.0)
- [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](codespell-project/codespell@v2.2.5...v2.2.6)
- [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](asottile/setup-cfg-fmt@v2.4.0...v2.5.0)

* use black mirror

* fixup

* typo

* capture autopep8 output

* ok scrap 3.12

* revert

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] and MarcoGorelli committed Nov 25, 2023
1 parent f064db4 commit 5125513
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
21 changes: 11 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
exclude: ^tests/data/
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: debug-statements
- repo: https://github.com/pre-commit/pre-commit
rev: v3.4.0
rev: v3.5.0
hooks:
- id: validate_manifest
- repo: https://github.com/psf/black
rev: 23.9.1
- repo: https://github.com/hauntsaninja/black-pre-commit-mirror
# black compiled with mypyc
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
rev: v3.1.0
hooks:
- id: prettier
exclude: ^README\.md$
- repo: https://github.com/PyCQA/pylint
rev: v3.0.0a7
rev: v3.0.1
hooks:
- id: pylint
files: ^(nbqa|tests)/
Expand All @@ -50,13 +51,13 @@ repos:
args: [-v, --fail-under=100]
files: ^nbqa/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.7.0
hooks:
- id: mypy
exclude: ^docs/
additional_dependencies: [types-setuptools, types-toml]
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand All @@ -65,7 +66,7 @@ repos:
hooks:
- id: auto-walrus
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
files: \.(py|rst|md)$
Expand All @@ -80,7 +81,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.4.0
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/PyCQA/autoflake
Expand Down
5 changes: 3 additions & 2 deletions nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ def _fixup_newlines(
) -> tuple[dict[str, dict[str, int]], dict[str, dict[str, int]]]:
"""Run autopep8 to remove false-positives due to spaces between cells."""
new_lines_before = _record_newlines(args, first_passes, nb_to_tmp_mapping)
subprocess.run(
_ = subprocess.run(
[sys.executable, "-m", "autopep8", "--select=E3", "--in-place", *args],
capture_output=True, # capture output to not show users irrelevant warning
)
new_lines_after = _record_newlines(args, first_passes, nb_to_tmp_mapping)
return (new_lines_before, new_lines_after)
Expand Down Expand Up @@ -723,7 +724,7 @@ def _main(cli_args: CLIArgs, configs: Configs) -> int:
Parameters
----------
cli_args
Commanline arguments passed to nbqa.
Commandline arguments passed to nbqa.
configs
Configuration passed to nbqa from commandline or via a config file
Expand Down
2 changes: 2 additions & 0 deletions tests/test_hash_collision.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Check what happens if cell separator appears in notebook."""
import os

import pytest
from _pytest.capture import CaptureFixture
from _pytest.monkeypatch import MonkeyPatch

from nbqa.__main__ import main


@pytest.mark.skip(reason="too slow - TODO how to re-enable / speedup?")
def test_hash_collision(monkeypatch: MonkeyPatch, capsys: CaptureFixture) -> None:
"""Check hash collision error message."""
path = os.path.join("tests", "data", "notebook_for_testing.ipynb")
Expand Down
1 change: 1 addition & 0 deletions tests/test_runtime_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_unable_to_reconstruct_message_pythonpath(monkeypatch: "MonkeyPatch") ->
assert output.returncode == expected_returncode


@pytest.mark.skip(reason="too slow - TODO how to re-enable / speedup?")
def test_unable_to_parse(capsys: "CaptureFixture") -> None:
"""Check error message shows if we're unable to parse notebook."""
path = Path("tests") / "data/invalid_notebook.ipynb"
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/test_pylint_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def test_pylint_works(capsys: "CaptureFixture") -> None:

expected_out = (
"************* Module tests.data.notebook_for_testing\n"
f"{notebook1}:cell_2:19:8: C0303: Trailing whitespace (trailing-whitespace)\n"
f"{notebook1}:cell_2:15:11: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)\n" # noqa: E501
f"{notebook1}:cell_2:19:8: C0303: Trailing whitespace (trailing-whitespace)\n" # noqa: E501
f"{notebook1}:cell_2:15:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)\n" # noqa: E501
f'{notebook1}:cell_4:1:0: C0413: Import "from random import randint" should be placed at the top of the module (wrong-import-position)\n' # noqa: E501
f'{notebook1}:cell_5:1:0: C0413: Import "import pprint" should be placed at the top of the module (wrong-import-position)\n' # noqa: E501
f'{notebook1}:cell_5:2:0: C0413: Import "import sys" should be placed at the top of the module (wrong-import-position)\n' # noqa: E501
Expand Down
12 changes: 6 additions & 6 deletions tests/tools/test_ruff_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ def test_ruff_works(

out, err = capsys.readouterr()
expected_out = (
f"{expected_path_1}:cell_1:1:8: F401 [*] `os` imported but unused\n"
f"{expected_path_1}:cell_1:3:8: F401 [*] `glob` imported but unused\n"
f"{expected_path_1}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n"
"Found 13 errors.\n"
"[*] 10 fixable with the `--fix` option.\n"
f"{expected_path_0}:cell_1:1:8: F401 [*] `os` imported but unused\n"
f"{expected_path_0}:cell_1:3:8: F401 [*] `glob` imported but unused\n"
f"{expected_path_0}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n"
f"{expected_path_0}:cell_4:1:1: E402 Module level import not at top of file\n"
f"{expected_path_0}:cell_4:1:20: F401 [*] `random.randint` imported but unused\n"
f"{expected_path_0}:cell_5:1:1: E402 Module level import not at top of file\n"
f"{expected_path_0}:cell_5:2:1: E402 Module level import not at top of file\n"
f"{expected_path_1}:cell_1:1:8: F401 [*] `os` imported but unused\n"
f"{expected_path_1}:cell_1:3:8: F401 [*] `glob` imported but unused\n"
f"{expected_path_1}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n"
f"{expected_path_2}:cell_1:1:8: F401 [*] `os` imported but unused\n"
f"{expected_path_2}:cell_1:3:8: F401 [*] `glob` imported but unused\n"
f"{expected_path_2}:cell_1:5:8: F401 [*] `nbqa` imported but unused\n"
"Found 13 errors.\n"
"[*] 10 potentially fixable with the --fix option.\n"
f"{expected_path_2}:cell_1:5:8: F401 [*] `nbqa` imported but unused"
)
assert "\n".join(sorted(out.replace("\r\n", "\n").splitlines())) == "\n".join(
sorted(expected_out.splitlines())
Expand Down

0 comments on commit 5125513

Please sign in to comment.