Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typing #1408

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ repos:
- id: mypy
# Avoid error: Duplicate module named 'setup'
# https://github.com/python/mypy/issues/4008
# Keep exclude in sync with mypy own excludes
exclude: ^tests/test_data/
additional_dependencies:
- click==8.0.1
- pep517==0.10.0
- toml==0.10.2
- pip==20.3.4
- repo: https://github.com/PyCQA/bandit
rev: 1.7.0
hooks:
Expand Down
8 changes: 5 additions & 3 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shlex
import sys
import tempfile
from typing import Any, BinaryIO, List, Optional, Tuple, cast
from typing import IO, Any, BinaryIO, List, Optional, Tuple, Union, cast

import click
from click.utils import LazyFile, safecall
Expand Down Expand Up @@ -231,7 +231,7 @@ def cli(
annotate: bool,
upgrade: bool,
upgrade_packages: Tuple[str, ...],
output_file: Optional[LazyFile],
output_file: Union[LazyFile, IO[Any], None],
allow_unsafe: bool,
generate_hashes: bool,
reuse_hashes: bool,
Expand Down Expand Up @@ -282,7 +282,9 @@ def cli(

# Close the file at the end of the context execution
assert output_file is not None
ctx.call_on_close(safecall(output_file.close_intelligently))
# only LazyFile has close_intelligently, newer IO[Any] does not
if isinstance(output_file, LazyFile): # pragma: no cover
ctx.call_on_close(safecall(output_file.close_intelligently))

###
# Setup
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ warn_return_any = true
warn_unused_configs = true
warn_unused_ignores = true

# Avoid error: Duplicate module named 'setup'
# https://github.com/python/mypy/issues/4008
exclude = ^tests/test_data/
ssbarnea marked this conversation as resolved.
Show resolved Hide resolved

[mypy-tests.*]
disallow_untyped_defs = false