Skip to content

Commit a68a19d

Browse files
committed
fixes for mypy 1.11
1 parent 88317dd commit a68a19d

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ repos:
4040
rev: v1.11.0
4141
hooks:
4242
- id: mypy
43-
additional_dependencies: [types-all]
43+
additional_dependencies: [types-pyyaml]
4444
exclude: ^testing/resources/

pre_commit/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def cmd_output_p(
205205
def _handle_readonly(
206206
func: Callable[[str], object],
207207
path: str,
208-
exc: Exception,
208+
exc: BaseException,
209209
) -> None:
210210
if (
211211
func in (os.rmdir, os.remove, os.unlink) and
@@ -223,7 +223,7 @@ def _handle_readonly(
223223
def _handle_readonly_old(
224224
func: Callable[[str], object],
225225
path: str,
226-
excinfo: tuple[type[Exception], Exception, TracebackType],
226+
excinfo: tuple[type[BaseException], BaseException, TracebackType],
227227
) -> None:
228228
return _handle_readonly(func, path, excinfo[1])
229229

tests/conftest.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,36 +209,25 @@ def log_info_mock():
209209
yield mck
210210

211211

212-
class FakeStream:
213-
def __init__(self):
214-
self.data = io.BytesIO()
215-
216-
def write(self, s):
217-
self.data.write(s)
218-
219-
def flush(self):
220-
pass
221-
222-
223212
class Fixture:
224-
def __init__(self, stream):
213+
def __init__(self, stream: io.BytesIO) -> None:
225214
self._stream = stream
226215

227-
def get_bytes(self):
216+
def get_bytes(self) -> bytes:
228217
"""Get the output as-if no encoding occurred"""
229-
data = self._stream.data.getvalue()
230-
self._stream.data.seek(0)
231-
self._stream.data.truncate()
218+
data = self._stream.getvalue()
219+
self._stream.seek(0)
220+
self._stream.truncate()
232221
return data.replace(b'\r\n', b'\n')
233222

234-
def get(self):
223+
def get(self) -> str:
235224
"""Get the output assuming it was written as UTF-8 bytes"""
236225
return self.get_bytes().decode()
237226

238227

239228
@pytest.fixture
240229
def cap_out():
241-
stream = FakeStream()
230+
stream = io.BytesIO()
242231
write = functools.partial(output.write, stream=stream)
243232
write_line_b = functools.partial(output.write_line_b, stream=stream)
244233
with mock.patch.multiple(output, write=write, write_line_b=write_line_b):

0 commit comments

Comments
 (0)