Skip to content

Commit

Permalink
Ignore mypy errors due to method assignment during patching
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Mar 24, 2023
1 parent a3062a1 commit e8440b6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/poetry_relax/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@

@contextlib.contextmanager
def patch_io_writes(io: "IO", patch_function: Callable):
"""
Patches writes to the given IO object to call the `patch_function`.
"""
write_line = io.write_line
write = io.write
io.write_line = functools.partial(patch_function, write_line)
io.write = functools.partial(patch_function, write)

# See https://github.com/python/mypy/issues/708 for method override type ignores
io.write_line = functools.partial(patch_function, write_line) # type: ignore
io.write = functools.partial(patch_function, write) # type: ignore

try:
yield
finally:
io.write_line = write_line
io.write = write
io.write_line = write_line # type: ignore
io.write = write # type:ignore


def run_installer_update(
Expand Down

0 comments on commit e8440b6

Please sign in to comment.