bpo-39481: PEP 585 for difflib, filecmp, fileinput by emmatyping · Pull Request #19422 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/difflib.py
4 changes: 4 additions & 0 deletions Lib/filecmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import stat
from itertools import filterfalse
from types import GenericAlias

__all__ = ['clear_cache', 'cmp', 'dircmp', 'cmpfiles', 'DEFAULT_IGNORES']

Expand Down Expand Up @@ -247,6 +248,9 @@ def __getattr__(self, attr):
self.methodmap[attr](self)
return getattr(self, attr)

__class_getitem__ = classmethod(GenericAlias)


def cmpfiles(a, b, common, shallow=True):
"""Compare common files in two directories.

Expand Down
3 changes: 3 additions & 0 deletions Lib/fileinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"""

import sys, os
from types import GenericAlias

__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno",
"fileno", "isfirstline", "isstdin", "FileInput", "hook_compressed",
Expand Down Expand Up @@ -391,6 +392,8 @@ def isfirstline(self):
def isstdin(self):
return self._isstdin

__class_getitem__ = classmethod(GenericAlias)


def hook_compressed(filename, mode):
ext = os.path.splitext(filename)[1]
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_genericalias.py