Skip to content

Commit

Permalink
Merge pull request #7977 from deveshks/add-mypy-annotations-commands
Browse files Browse the repository at this point in the history
Added type annotations to pip._internal.commands.check
  • Loading branch information
pradyunsg committed Apr 9, 2020
2 parents ea1295b + c2fdf4a commit c8e4afa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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

0 comments on commit c8e4afa

Please sign in to comment.