FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[pre-commit.ci] pre-commit autoupdate by pre-commit-ci[bot] · Pull Request #3264 · pre-commit/pre-commit · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .yaml  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.11.0
hooks:
- id: mypy
additional_dependencies: [types-all]
additional_dependencies: [types-pyyaml]
exclude: ^testing/resources/
4 changes: 2 additions & 2 deletions pre_commit/util.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def cmd_output_p(
def _handle_readonly(
func: Callable[[str], object],
path: str,
exc: Exception,
exc: BaseException,
) -> None:
if (
func in (os.rmdir, os.remove, os.unlink) and
Expand All @@ -223,7 +223,7 @@ def _handle_readonly(
def _handle_readonly_old(
func: Callable[[str], object],
path: str,
excinfo: tuple[type[Exception], Exception, TracebackType],
excinfo: tuple[type[BaseException], BaseException, TracebackType],
) -> None:
return _handle_readonly(func, path, excinfo[1])

Expand Down
25 changes: 7 additions & 18 deletions tests/conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,25 @@ def log_info_mock():
yield mck


class FakeStream:
def __init__(self):
self.data = io.BytesIO()

def write(self, s):
self.data.write(s)

def flush(self):
pass


class Fixture:
def __init__(self, stream):
def __init__(self, stream: io.BytesIO) -> None:
self._stream = stream

def get_bytes(self):
def get_bytes(self) -> bytes:
"""Get the output as-if no encoding occurred"""
data = self._stream.data.getvalue()
self._stream.data.seek(0)
self._stream.data.truncate()
data = self._stream.getvalue()
self._stream.seek(0)
self._stream.truncate()
return data.replace(b'\r\n', b'\n')

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


@pytest.fixture
def cap_out():
stream = FakeStream()
stream = io.BytesIO()
write = functools.partial(output.write, stream=stream)
write_line_b = functools.partial(output.write_line_b, stream=stream)
with mock.patch.multiple(output, write=write, write_line_b=write_line_b):
Expand Down

Back | FazBrowse Home | New Git URL