diff --git a/CHANGES.rst b/CHANGES.rst index 903134d61..edd23ac0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,7 +10,8 @@ Added - Display exit code in parentheses after error message. - Do not reformat renamed files. - The ``--preview`` configuration flag is now supported in the configuration files for - Darker and Black + Darker and Black. +- Prevent Pylint from updating beyond version 3.2.7 due to dropped Python 3.8 support. - The ``--formatter=black`` option (the default) has been added in preparation for future formatters. - ``--formatter=none`` now skips running Black. This is useful when you only want to run @@ -19,6 +20,8 @@ Added Black support. - pyupgrade_ is now supported as a formatter plugin. Note that changes from pyupgrade are applied on a per-file basis, not only for modified lines as with Black_ and Ruff_. +- For linting Darker itself, upgrade to Pylint 3.3.0 or later, and add ignores for the + ``too-many-positional-arguments`` message. Removed ------- diff --git a/constraints-oldest.txt b/constraints-oldest.txt index c7154ae72..ce569b25b 100644 --- a/constraints-oldest.txt +++ b/constraints-oldest.txt @@ -12,6 +12,7 @@ flake8-comprehensions==3.7.0 flynt==0.76 mypy==0.990 Pygments==2.4.0 +pylint==3.3.0 pytest==6.2.0 pytest-kwparametrize==0.0.3 regex==2021.4.4 diff --git a/setup.cfg b/setup.cfg index 0016a1517..e36137ecd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -74,7 +74,7 @@ test = pathspec # to test `gen_python_files` in `test_black_diff.py` pydocstyle pygments - pylint<=3.2.7 # pylint 3.3.0 dropped Python 3.8 support + pylint>=3.3.0 pylint-per-file-ignores pytest>=6.2.0 pytest-kwparametrize>=0.0.3 diff --git a/src/darker/__main__.py b/src/darker/__main__.py index 3689a0e82..8447dc775 100644 --- a/src/darker/__main__.py +++ b/src/darker/__main__.py @@ -58,7 +58,7 @@ ProcessedDocument = Tuple[Path, TextDocument, TextDocument] -def format_edited_parts( # noqa: PLR0913 # pylint: disable=too-many-arguments +def format_edited_parts( # noqa: PLR0913 root: Path, changed_files: Collection[Path], exclude: Exclusions, @@ -67,6 +67,7 @@ def format_edited_parts( # noqa: PLR0913 # pylint: disable=too-many-arguments report_unmodified: bool, workers: int = 1, ) -> Generator[ProcessedDocument, None, None]: + # pylint: disable=too-many-arguments,too-many-positional-arguments """Black (and optional isort and flynt) formatting modified chunks in a set of files Files inside given directories and excluded by Black's configuration are not @@ -121,7 +122,7 @@ def _modify_and_reformat_single_file( # noqa: PLR0913 revrange: RevisionRange, formatter: BaseFormatter, ) -> ProcessedDocument: - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments,too-many-positional-arguments """Black, isort and/or flynt formatting for modified chunks in a single file :param root: Root directory for the relative path @@ -179,7 +180,7 @@ def _reformat_and_flynt_single_file( # noqa: PLR0913 has_isort_changes: bool, formatter: BaseFormatter, ) -> TextDocument: - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals """In a Python file, reformat chunks with edits since the last commit using Black :param root: The common root of all files to reformat @@ -306,7 +307,7 @@ def _maybe_reformat_single_file( def _drop_changes_on_unedited_lines( - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments,too-many-positional-arguments new_chunks: List[DiffChunk], abspath_in_rev2: Path, relpath_in_repo: Path, diff --git a/src/darker/import_sorting.py b/src/darker/import_sorting.py index bcf284a60..cdd9e46f9 100644 --- a/src/darker/import_sorting.py +++ b/src/darker/import_sorting.py @@ -51,7 +51,7 @@ class IsortArgs(TypedDict, total=False): settings_path: str -def apply_isort( # pylint: disable=too-many-arguments +def apply_isort( # noqa: PLR0913 content: TextDocument, src: Path, exclude: Collection[str], @@ -59,6 +59,7 @@ def apply_isort( # pylint: disable=too-many-arguments config: Optional[str] = None, line_length: Optional[int] = None, ) -> TextDocument: + # pylint: disable=too-many-arguments,too-many-positional-arguments """Run isort on the given Python source file content :param content: The contents of the Python source code file to sort imports in diff --git a/src/darker/tests/helpers.py b/src/darker/tests/helpers.py index bd587ccbc..7d7960971 100644 --- a/src/darker/tests/helpers.py +++ b/src/darker/tests/helpers.py @@ -1,13 +1,19 @@ """Helper functions for unit tests""" +from __future__ import annotations + import sys from contextlib import contextmanager from types import ModuleType -from typing import Generator, Optional +from typing import TYPE_CHECKING, Generator, Optional from unittest.mock import patch from darkgraylib.testtools.git_repo_plugin import GitRepoFixture +if TYPE_CHECKING: + import pytest + from _pytest.fixtures import SubRequest + @contextmanager def _package_present( @@ -56,7 +62,9 @@ def flynt_present(present: bool) -> Generator[None, None, None]: @contextmanager -def unix_and_windows_newline_repos(request, tmp_path_factory): +def unix_and_windows_newline_repos( + request: SubRequest, tmp_path_factory: pytest.TempPathFactory +) -> Generator[dict[str, GitRepoFixture], None, None]: """Create temporary repositories for Unix and windows newlines separately.""" with GitRepoFixture.context( request, tmp_path_factory diff --git a/src/darker/tests/test_command_line.py b/src/darker/tests/test_command_line.py index 24cc30072..d8bb3f15d 100644 --- a/src/darker/tests/test_command_line.py +++ b/src/darker/tests/test_command_line.py @@ -1,6 +1,6 @@ """Unit tests for `darker.command_line` and `darker.__main__`.""" -# pylint: disable=too-many-arguments,too-many-locals +# pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals # pylint: disable=no-member,redefined-outer-name,unused-argument,use-dict-literal from __future__ import annotations diff --git a/src/darker/tests/test_config.py b/src/darker/tests/test_config.py index 62cb7079c..a7e7e1171 100644 --- a/src/darker/tests/test_config.py +++ b/src/darker/tests/test_config.py @@ -1,6 +1,7 @@ """Tests for `darker.config`""" -# pylint: disable=unused-argument,too-many-arguments,use-dict-literal +# pylint: disable=unused-argument,too-many-arguments,too-many-positional-arguments +# pylint: disable=use-dict-literal from argparse import Namespace from pathlib import Path diff --git a/src/darker/tests/test_formatters_black.py b/src/darker/tests/test_formatters_black.py index 9f2a1273f..d21b2ed77 100644 --- a/src/darker/tests/test_formatters_black.py +++ b/src/darker/tests/test_formatters_black.py @@ -1,6 +1,6 @@ """Unit tests for `darker.black_formatter`""" -# pylint: disable=too-many-arguments,use-dict-literal +# pylint: disable=too-many-arguments,too-many-positional-arguments,use-dict-literal import re import sys @@ -198,9 +198,10 @@ def test_read_config(tmpdir, option_name_delimiter, config_path, config_lines, e extend_exclude=None, force_exclude=None, ) -def test_filter_python_files( # pylint: disable=too-many-arguments +def test_filter_python_files( tmp_path, monkeypatch, exclude, extend_exclude, force_exclude, expect ): + # pylint: disable=too-many-arguments,too-many-positional-arguments """``filter_python_files()`` skips excluded files correctly""" monkeypatch.chdir(tmp_path) names = { diff --git a/src/darker/tests/test_fstring.py b/src/darker/tests/test_fstring.py index 749d44c1a..d9122d178 100644 --- a/src/darker/tests/test_fstring.py +++ b/src/darker/tests/test_fstring.py @@ -1,6 +1,7 @@ """Tests for :mod:`darker.fstring`""" -# pylint: disable=unused-argument,protected-access,too-many-arguments +# pylint: disable=protected-access +# pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument from importlib import reload from pathlib import Path diff --git a/src/darker/tests/test_git.py b/src/darker/tests/test_git.py index 8cacd2228..a0ec5331c 100644 --- a/src/darker/tests/test_git.py +++ b/src/darker/tests/test_git.py @@ -1,16 +1,18 @@ """Unit tests for :mod:`darker.git`""" -# pylint: disable=no-member,protected-access,redefined-outer-name,too-many-arguments -# pylint: disable=too-many-lines,use-dict-literal +# pylint: disable=no-member,protected-access,redefined-outer-name,use-dict-literal +# pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-lines import os from pathlib import Path from subprocess import DEVNULL, check_call # nosec from textwrap import dedent # nosec from types import SimpleNamespace +from typing import Generator from unittest.mock import ANY, patch import pytest +from _pytest.fixtures import SubRequest from darker import git from darkgraylib.git import WORKTREE, RevisionRange @@ -321,7 +323,9 @@ def test_git_get_modified_python_files( @pytest.fixture(scope="module") -def git_get_modified_python_files_revision_range_repo(request, tmp_path_factory): +def git_get_modified_python_files_revision_range_repo( + request: SubRequest, tmp_path_factory: pytest.TempPathFactory +) -> Generator[GitRepoFixture, None, None]: """Fixture for a Git repository with multiple commits and branches.""" yield from branched_repo(request, tmp_path_factory) diff --git a/src/darker/tests/test_import_sorting.py b/src/darker/tests/test_import_sorting.py index 19d02d4aa..91dc409fd 100644 --- a/src/darker/tests/test_import_sorting.py +++ b/src/darker/tests/test_import_sorting.py @@ -1,7 +1,7 @@ """Tests for :mod:`darker.import_sorting`""" -# pylint: disable=no-member,protected-access,redefined-outer-name,too-many-arguments -# pylint: disable=unused-argument,use-dict-literal +# pylint: disable=no-member,protected-access,redefined-outer-name,use-dict-literal +# pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument from importlib import reload from pathlib import Path diff --git a/src/darker/tests/test_main.py b/src/darker/tests/test_main.py index 6ef0b77ba..334685a52 100644 --- a/src/darker/tests/test_main.py +++ b/src/darker/tests/test_main.py @@ -1,8 +1,8 @@ """Unit tests for :mod:`darker.__main__`""" -# pylint: disable=too-many-locals,use-implicit-booleaness-not-comparison,unused-argument -# pylint: disable=no-member,protected-access,redefined-outer-name,too-many-arguments -# pylint: disable=use-dict-literal +# pylint: disable=no-member,too-many-locals,use-implicit-booleaness-not-comparison +# pylint: disable=protected-access,redefined-outer-name,use-dict-literal, +# pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument import random import re diff --git a/src/darker/tests/test_main_format_edited_parts.py b/src/darker/tests/test_main_format_edited_parts.py index 9160950f2..bcb5c70cd 100644 --- a/src/darker/tests/test_main_format_edited_parts.py +++ b/src/darker/tests/test_main_format_edited_parts.py @@ -1,7 +1,8 @@ """Tests for the `darker.__main__.format_edited_parts` function.""" -# pylint: disable=no-member,redefined-outer-name,too-many-arguments,use-dict-literal -# pylint: disable=use-implicit-booleaness-not-comparison +# pylint: disable=no-member,redefined-outer-name +# pylint: disable=too-many-arguments,too-many-positional-arguments +# pylint: disable=use-dict-literal,use-implicit-booleaness-not-comparison import logging import re diff --git a/src/darker/tests/test_main_reformat_and_flynt_single_file.py b/src/darker/tests/test_main_reformat_and_flynt_single_file.py index 7e14d6e1a..cfd8f217c 100644 --- a/src/darker/tests/test_main_reformat_and_flynt_single_file.py +++ b/src/darker/tests/test_main_reformat_and_flynt_single_file.py @@ -1,6 +1,7 @@ """Unit tests for `darker.__main__._reformat_and_flynt_single_file`.""" -# pylint: disable=no-member,redefined-outer-name,too-many-arguments,use-dict-literal +# pylint: disable=no-member,redefined-outer-name +# pylint: disable=too-many-arguments,too-many-positional-arguments,use-dict-literal from pathlib import Path from textwrap import dedent diff --git a/src/darker/tests/test_main_revision.py b/src/darker/tests/test_main_revision.py index d64dcc84f..64dfb0414 100644 --- a/src/darker/tests/test_main_revision.py +++ b/src/darker/tests/test_main_revision.py @@ -1,6 +1,7 @@ """Unit tests for the ``--revision`` argument in `darker.main`""" -# pylint: disable=no-member,redefined-outer-name,too-many-arguments,use-dict-literal +# pylint: disable=no-member,redefined-outer-name +# pylint: disable=too-many-arguments,too-many-positional-arguments,use-dict-literal import pytest diff --git a/src/darker/tests/test_main_stdin_filename.py b/src/darker/tests/test_main_stdin_filename.py index aab1d189c..ab446e8c7 100644 --- a/src/darker/tests/test_main_stdin_filename.py +++ b/src/darker/tests/test_main_stdin_filename.py @@ -1,6 +1,7 @@ """Tests for `darker.__main__.main` and the ``--stdin-filename`` option""" -# pylint: disable=no-member,redefined-outer-name,too-many-arguments,use-dict-literal +# pylint: disable=no-member,redefined-outer-name +# pylint: disable=too-many-arguments,too-many-positional-arguments,use-dict-literal from __future__ import annotations