[mypy] Fix type annotations for strings (#4641)

* Fix mypy error for min_cost_string_conversion.py

* Fix mypy error for manacher.py

* Fix mypy error for aho_corasick.py
This commit is contained in:
imp
2021-08-25 19:35:36 +08:00
committed by GitHub
parent 78a5d3a558
commit 5e7eed610c
3 changed files with 29 additions and 26 deletions

View File

@ -1,5 +1,3 @@
from typing import List, Tuple
"""
Algorithm for calculating the most cost-efficient sequence for converting one string
into another.
@ -18,7 +16,7 @@ def compute_transform_tables(
replace_cost: int,
delete_cost: int,
insert_cost: int,
) -> Tuple[List[int], List[str]]:
) -> tuple[list[list[int]], list[list[str]]]:
source_seq = list(source_string)
destination_seq = list(destination_string)
len_source_seq = len(source_seq)
@ -28,7 +26,7 @@ def compute_transform_tables(
[0 for _ in range(len_destination_seq + 1)] for _ in range(len_source_seq + 1)
]
ops = [
[0 for _ in range(len_destination_seq + 1)] for _ in range(len_source_seq + 1)
["0" for _ in range(len_destination_seq + 1)] for _ in range(len_source_seq + 1)
]
for i in range(1, len_source_seq + 1):
@ -59,7 +57,7 @@ def compute_transform_tables(
return costs, ops
def assemble_transformation(ops: List[str], i: int, j: int) -> List[str]:
def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
if i == 0 and j == 0:
return []
else: