From 23e380ac83e1f8287a346263375437a605ab98fc Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 5 Apr 2020 05:12:29 -0700 Subject: [PATCH] add overload to difflib.get_close_matches (#3908) Fixes #3906. Fixes #2067. --- stdlib/2and3/difflib.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/difflib.pyi b/stdlib/2and3/difflib.pyi index 5b285e070..4804ef820 100644 --- a/stdlib/2and3/difflib.pyi +++ b/stdlib/2and3/difflib.pyi @@ -3,7 +3,7 @@ import sys from typing import ( Any, TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple, - Generic, Optional, Text, Union, AnyStr + Generic, Optional, Text, Union, AnyStr, overload ) _T = TypeVar('_T') @@ -38,6 +38,11 @@ class SequenceMatcher(Generic[_T]): def quick_ratio(self) -> float: ... def real_quick_ratio(self) -> float: ... +# mypy thinks the signatures of the overloads overlap, but the types still work fine +@overload +def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], # type: ignore + n: int = ..., cutoff: float = ...) -> List[AnyStr]: ... +@overload def get_close_matches(word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ...