Skip to content

Commit

Permalink
Make validate_opcodes() public, used from Darker
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Mar 2, 2024
1 parent 729fb36 commit e3f7b91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/darkgraylib/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def diff_and_get_opcodes(
return opcodes


def _validate_opcodes(opcodes: List[Tuple[str, int, int, int, int]]) -> None:
def validate_opcodes(opcodes: List[Tuple[str, int, int, int, int]]) -> None:
"""Make sure every other opcode is an 'equal' tag"""
if not all(
(tag1 == "equal") != (tag2 == "equal")
Expand Down Expand Up @@ -131,7 +131,7 @@ def opcodes_to_edit_linenums( # pylint: disable=too-many-locals
"""
if not opcodes:
return
_validate_opcodes(opcodes)
validate_opcodes(opcodes)

# Calculate the last line number beyond which we won't extend with extra context
# lines
Expand Down Expand Up @@ -174,7 +174,7 @@ def opcodes_to_chunks(
lines for each chunk and concatenating them together.
"""
_validate_opcodes(opcodes)
validate_opcodes(opcodes)
for _tag, src_start, src_end, dst_start, dst_end in opcodes:
yield src_start + 1, src.lines[src_start:src_end], dst.lines[dst_start:dst_end]

Expand Down Expand Up @@ -223,7 +223,7 @@ def map_unmodified_lines(src: TextDocument, dst: TextDocument) -> Dict[int, int]
"""
opcodes = diff_and_get_opcodes(src, dst)
_validate_opcodes(opcodes)
validate_opcodes(opcodes)
if not src.string and not dst.string:
# empty files may get linter messages on line 1
return {1: 1}
Expand Down

0 comments on commit e3f7b91

Please sign in to comment.