Skip to content

Commit 23e380a

Browse files
add overload to difflib.get_close_matches (#3908)
Fixes #3906. Fixes #2067.
1 parent 12b53fa commit 23e380a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stdlib/2and3/difflib.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
from typing import (
55
Any, TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple,
6-
Generic, Optional, Text, Union, AnyStr
6+
Generic, Optional, Text, Union, AnyStr, overload
77
)
88

99
_T = TypeVar('_T')
@@ -38,6 +38,11 @@ class SequenceMatcher(Generic[_T]):
3838
def quick_ratio(self) -> float: ...
3939
def real_quick_ratio(self) -> float: ...
4040

41+
# mypy thinks the signatures of the overloads overlap, but the types still work fine
42+
@overload
43+
def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], # type: ignore
44+
n: int = ..., cutoff: float = ...) -> List[AnyStr]: ...
45+
@overload
4146
def get_close_matches(word: Sequence[_T], possibilities: Iterable[Sequence[_T]],
4247
n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ...
4348

0 commit comments

Comments
 (0)