Skip to content

Commit 384f292

Browse files
federico-e-martinezanselor
authored andcommitted
changes based on formatter and doc jobs
1 parent db87f12 commit 384f292

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cmd2/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,9 @@ def similarity_function(s1: str, s2: str) -> float:
12741274
MIN_SIMIL_TO_CONSIDER = 0.7
12751275

12761276

1277-
def suggest_similar(requested_command: str, options: Iterable[str],
1278-
similarity_function_to_use: Optional[Callable[[str, str], float]] = None) -> Optional[str]:
1277+
def suggest_similar(
1278+
requested_command: str, options: Iterable[str], similarity_function_to_use: Optional[Callable[[str, str], float]] = None
1279+
) -> Optional[str]:
12791280
"""
12801281
Given a requested command and an iterable of possible options
12811282
returns the most similar (if any is similar)

docs/api/utils.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ Miscellaneous
9999
.. autofunction:: cmd2.utils.natural_sort
100100

101101
.. autofunction:: cmd2.utils.suggest_similar
102+

tests/test_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,20 +889,18 @@ def test_similarity_without_good_canididates():
889889

890890

891891
def test_similarity_overwrite_function():
892-
suggested_command = cu.suggest_similar("test", ["history", "test"])
892+
options = ["history", "test"]
893+
suggested_command = cu.suggest_similar("test", options)
893894
assert suggested_command == 'test'
894895

895896
def custom_similarity_function(s1, s2):
896897
return 1.0 if 'history' in (s1, s2) else 0.0
897898

898-
suggested_command = cu.suggest_similar("test", ["history", "test"],
899-
similarity_function_to_use=custom_similarity_function)
899+
suggested_command = cu.suggest_similar("test", options, similarity_function_to_use=custom_similarity_function)
900900
assert suggested_command == 'history'
901901

902-
suggested_command = cu.suggest_similar("history", ["history", "test"],
903-
similarity_function_to_use=custom_similarity_function)
902+
suggested_command = cu.suggest_similar("history", options, similarity_function_to_use=custom_similarity_function)
904903
assert suggested_command == 'history'
905904

906-
suggested_command = cu.suggest_similar("test", ["test"],
907-
similarity_function_to_use=custom_similarity_function)
905+
suggested_command = cu.suggest_similar("test", ["test"], similarity_function_to_use=custom_similarity_function)
908906
assert suggested_command is None

0 commit comments

Comments
 (0)