diff options
author | Ethan Smith <ethan@ethanhs.me> | 2020-04-10 04:47:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 04:47:31 (GMT) |
commit | e3ec44d692d9442e640cf5b2d8708157a65cec3e (patch) | |
tree | dc16382cb3ae14abfda9fb38257202bb1ab7b3d2 /Lib/difflib.py | |
parent | 7c4185d62d4aec486d82c3ad02acd878db2d3537 (diff) | |
download | cpython-e3ec44d692d9442e640cf5b2d8708157a65cec3e.zip cpython-e3ec44d692d9442e640cf5b2d8708157a65cec3e.tar.gz cpython-e3ec44d692d9442e640cf5b2d8708157a65cec3e.tar.bz2 |
bpo-39481: PEP 585 for difflib, filecmp, fileinput (#19422)
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r-- | Lib/difflib.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py index 5d75643..f2215d8 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -32,6 +32,7 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher', from heapq import nlargest as _nlargest from collections import namedtuple as _namedtuple +from types import GenericAlias Match = _namedtuple('Match', 'a b size') @@ -685,6 +686,9 @@ class SequenceMatcher: # shorter sequence return _calculate_ratio(min(la, lb), la + lb) + __class_getitem__ = classmethod(GenericAlias) + + def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. |