Skip to content

Commit

Permalink
Merge pull request #8235 from deveshks/remove-pretty-arg-from-mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored May 18, 2020
2 parents c65625b + 4d208b0 commit d0ab9bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
files: \.py$

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.760
rev: v0.770
hooks:
- id: mypy
exclude: docs|tests
Expand Down
Empty file.
13 changes: 11 additions & 2 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.typing import MYPY_CHECK_RUNNING, cast
from pip._internal.utils.unpacking import current_umask, unpack_file
from pip._internal.utils.wheel import parse_wheel

if MYPY_CHECK_RUNNING:
from email.message import Message
import typing # noqa F401
from typing import (
Dict, List, Optional, Sequence, Tuple, Any,
Iterable, Iterator, Callable, Set,
Expand Down Expand Up @@ -600,7 +601,15 @@ def _generate_file(path, **kwargs):
generated=generated,
lib_dir=lib_dir)
with _generate_file(record_path, **csv_io_kwargs('w')) as record_file:
writer = csv.writer(record_file)

# The type mypy infers for record_file using reveal_type
# is different for Python 3 (typing.IO[Any]) and
# Python 2 (typing.BinaryIO), leading us to explicitly
# cast to typing.IO[str] as a workaround
# for bad Python 2 behaviour
record_file_obj = cast('typing.IO[str]', record_file)

writer = csv.writer(record_file_obj)
writer.writerows(sorted_outrows(rows)) # sort to simplify testing


Expand Down

0 comments on commit d0ab9bd

Please sign in to comment.