mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
[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:
@ -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:
|
||||
|
Reference in New Issue
Block a user