diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2022-05-08 14:24:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 14:24:54 (GMT) |
commit | 5ed5c5612363538a1d73dbc3948fa70ca743ba2c (patch) | |
tree | 8c899d9fa32f89817d372f71bd5be18a6781b092 /Lib/csv.py | |
parent | 3680ebed7f3e529d01996dd0318601f9f0d02b4b (diff) | |
download | cpython-5ed5c5612363538a1d73dbc3948fa70ca743ba2c.zip cpython-5ed5c5612363538a1d73dbc3948fa70ca743ba2c.tar.gz cpython-5ed5c5612363538a1d73dbc3948fa70ca743ba2c.tar.bz2 |
Add __class_getitem__ to csv.DictReader and csv.DictWriter (#92393)
Diffstat (limited to 'Lib/csv.py')
-rw-r--r-- | Lib/csv.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -4,6 +4,7 @@ csv.py - read/write/investigate CSV files """ import re +import types from _csv import Error, __version__, writer, reader, register_dialect, \ unregister_dialect, get_dialect, list_dialects, \ field_size_limit, \ @@ -126,6 +127,8 @@ class DictReader: d[key] = self.restval return d + __class_getitem__ = classmethod(types.GenericAlias) + class DictWriter: def __init__(self, f, fieldnames, restval="", extrasaction="raise", @@ -156,6 +159,8 @@ class DictWriter: def writerows(self, rowdicts): return self.writer.writerows(map(self._dict_to_list, rowdicts)) + __class_getitem__ = classmethod(types.GenericAlias) + # Guard Sniffer's type checking against builds that exclude complex() try: complex |