comparison contrib/python-zstandard/tests/common.py @ 52668:5cc8deb96b48

pyupgrade: modernize calls to superclass methods This is the `legacy` fixer in `pyupgrade`, with the loop yielding the offset of `yield` statements commented out.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 05 Jan 2025 22:23:31 -0500
parents 5e84a96d865b
children
comparison
equal deleted inserted replaced
52667:73ab542565e0 52668:5cc8deb96b48
100 100
101 This allows us to access written data after close(). 101 This allows us to access written data after close().
102 """ 102 """
103 103
104 def __init__(self, *args, **kwargs): 104 def __init__(self, *args, **kwargs):
105 super(NonClosingBytesIO, self).__init__(*args, **kwargs) 105 super().__init__(*args, **kwargs)
106 self._saved_buffer = None 106 self._saved_buffer = None
107 107
108 def close(self): 108 def close(self):
109 self._saved_buffer = self.getvalue() 109 self._saved_buffer = self.getvalue()
110 return super(NonClosingBytesIO, self).close() 110 return super().close()
111 111
112 def getvalue(self): 112 def getvalue(self):
113 if self.closed: 113 if self.closed:
114 return self._saved_buffer 114 return self._saved_buffer
115 else: 115 else:
116 return super(NonClosingBytesIO, self).getvalue() 116 return super().getvalue()
117 117
118 118
119 class OpCountingBytesIO(NonClosingBytesIO): 119 class OpCountingBytesIO(NonClosingBytesIO):
120 def __init__(self, *args, **kwargs): 120 def __init__(self, *args, **kwargs):
121 self._flush_count = 0 121 self._flush_count = 0
122 self._read_count = 0 122 self._read_count = 0
123 self._write_count = 0 123 self._write_count = 0
124 return super(OpCountingBytesIO, self).__init__(*args, **kwargs) 124 return super().__init__(*args, **kwargs)
125 125
126 def flush(self): 126 def flush(self):
127 self._flush_count += 1 127 self._flush_count += 1
128 return super(OpCountingBytesIO, self).flush() 128 return super().flush()
129 129
130 def read(self, *args): 130 def read(self, *args):
131 self._read_count += 1 131 self._read_count += 1
132 return super(OpCountingBytesIO, self).read(*args) 132 return super().read(*args)
133 133
134 def write(self, data): 134 def write(self, data):
135 self._write_count += 1 135 self._write_count += 1
136 return super(OpCountingBytesIO, self).write(data) 136 return super().write(data)
137 137
138 138
139 _source_files = [] 139 _source_files = []
140 140
141 141