diff --git a/constraints-oldest.txt b/constraints-oldest.txt index 1b729c34a..624813769 100644 --- a/constraints-oldest.txt +++ b/constraints-oldest.txt @@ -4,7 +4,7 @@ # interpreter and Python ependencies. Keep this up-to-date with minimum # versions in `setup.cfg`. black==22.3.0 -darkgraylib==1.3.1 +darkgraylib==1.3.2 defusedxml==0.7.1 flake8-2020==1.6.1 flake8-bugbear==22.1.11 diff --git a/setup.cfg b/setup.cfg index 7c949e7cb..49f5bc70a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ packages = find: install_requires = # NOTE: remember to keep `constraints-oldest.txt` in sync with these black>=22.3.0 - darkgraylib~=1.3.1 + darkgraylib~=1.3.2 graylint~=1.1.2 toml>=0.10.0 # NOTE: remember to keep `.github/workflows/python-package.yml` in sync diff --git a/src/darker/diff.py b/src/darker/diff.py index 83e7d9abd..c53012a77 100644 --- a/src/darker/diff.py +++ b/src/darker/diff.py @@ -65,7 +65,7 @@ """ import logging -from typing import Generator, List, Sequence, Tuple +from typing import Generator, List, Literal, Sequence, Tuple from darker.multiline_strings import find_overlap from darkgraylib.diff import diff_and_get_opcodes, validate_opcodes @@ -75,7 +75,9 @@ def opcodes_to_edit_linenums( # pylint: disable=too-many-locals - opcodes: List[Tuple[str, int, int, int, int]], + opcodes: List[ + Tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int] + ], context_lines: int, multiline_string_ranges: Sequence[Tuple[int, int]], ) -> Generator[int, None, None]: @@ -123,7 +125,9 @@ def opcodes_to_edit_linenums( # pylint: disable=too-many-locals def opcodes_to_chunks( - opcodes: List[Tuple[str, int, int, int, int]], + opcodes: List[ + Tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int] + ], src: TextDocument, dst: TextDocument, ) -> Generator[DiffChunk, None, None]: diff --git a/src/darker/tests/test_diff.py b/src/darker/tests/test_diff.py index ffdb1bb8e..6ab83b847 100644 --- a/src/darker/tests/test_diff.py +++ b/src/darker/tests/test_diff.py @@ -3,13 +3,11 @@ # pylint: disable=use-dict-literal from itertools import chain +from typing import List, Literal, Tuple import pytest -from darker.diff import ( - opcodes_to_chunks, - opcodes_to_edit_linenums, -) +from darker.diff import opcodes_to_chunks, opcodes_to_edit_linenums from darkgraylib.testtools.diff_helpers import ( EXPECT_OPCODES, FUNCTIONS2_PY, @@ -98,7 +96,9 @@ def test_opcodes_to_chunks(): ] -EXAMPLE_OPCODES = [ +EXAMPLE_OPCODES: List[ + Tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int] +] = [ # 0-based, end-exclusive ("replace", 0, 4, 0, 1), ("equal", 4, 6, 1, 3),