Skip to content

Added type annotations to pip._internal.commands.check #7977

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

Merged
merged 1 commit into from
Apr 9, 2020
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
Empty file.
4 changes: 4 additions & 0 deletions src/pip/_internal/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False
# There is currently a bug in python/typeshed mentioned at
# https://github.com/python/typeshed/issues/3906 which causes the
# return type of difflib.get_close_matches to be reported
# as List[Sequence[str]] whereas it should have been List[str]

from __future__ import absolute_import

Expand Down
14 changes: 10 additions & 4 deletions src/pip/_internal/commands/check.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# The following comment should be removed at some point in the future.
# mypy: disallow-untyped-defs=False

import logging

from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.operations.check import (
check_package_set,
create_package_set_from_installed,
)
from pip._internal.utils.misc import write_output
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

logger = logging.getLogger(__name__)

if MYPY_CHECK_RUNNING:
from typing import List, Any
from optparse import Values


class CheckCommand(Command):
"""Verify installed packages have compatible dependencies."""
Expand All @@ -20,6 +23,8 @@ class CheckCommand(Command):
%prog [options]"""

def run(self, options, args):
# type: (Values, List[Any]) -> int

package_set, parsing_probs = create_package_set_from_installed()
missing, conflicting = check_package_set(package_set)

Expand All @@ -40,6 +45,7 @@ def run(self, options, args):
)

if missing or conflicting or parsing_probs:
return 1
return ERROR
else:
write_output("No broken requirements found.")
return SUCCESS