Skip to content

Commit d0ab9bd

Browse files
authored
Merge pull request #8235 from deveshks/remove-pretty-arg-from-mypy
2 parents c65625b + 4d208b0 commit d0ab9bd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
files: \.py$
3030

3131
- repo: https://github.com/pre-commit/mirrors-mypy
32-
rev: v0.760
32+
rev: v0.770
3333
hooks:
3434
- id: mypy
3535
exclude: docs|tests

news/CDB04414-2228-431F-9F5D-AFF4C5C08D05.trivial

Whitespace-only changes.

src/pip/_internal/operations/install/wheel.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
3333
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file
3434
from pip._internal.utils.temp_dir import TempDirectory
35-
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
35+
from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
3636
from pip._internal.utils.unpacking import current_umask, unpack_file
3737
from pip._internal.utils.wheel import parse_wheel
3838

3939
if MYPY_CHECK_RUNNING:
4040
from email.message import Message
41+
import typing # noqa F401
4142
from typing import (
4243
Dict, List, Optional, Sequence, Tuple, Any,
4344
Iterable, Iterator, Callable, Set,
@@ -600,7 +601,15 @@ def _generate_file(path, **kwargs):
600601
generated=generated,
601602
lib_dir=lib_dir)
602603
with _generate_file(record_path, **csv_io_kwargs('w')) as record_file:
603-
writer = csv.writer(record_file)
604+
605+
# The type mypy infers for record_file using reveal_type
606+
# is different for Python 3 (typing.IO[Any]) and
607+
# Python 2 (typing.BinaryIO), leading us to explicitly
608+
# cast to typing.IO[str] as a workaround
609+
# for bad Python 2 behaviour
610+
record_file_obj = cast('typing.IO[str]', record_file)
611+
612+
writer = csv.writer(record_file_obj)
604613
writer.writerows(sorted_outrows(rows)) # sort to simplify testing
605614

606615

0 commit comments

Comments
 (0)