Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0f9d259
Add basic mypy support
pradyunsg Jun 14, 2017
bc637a8
:newspaper:
pradyunsg Jun 16, 2017
ed9208e
Improve mypy configuration
pradyunsg Jun 14, 2017
9fce241
Patch pkg_resources for mypy
pradyunsg Jun 15, 2017
8f92b55
Fix mypy warnings
pradyunsg Jun 15, 2017
da46ab2
Add type annotations to pip.configuration
pradyunsg Jun 15, 2017
711596b
Use pip.utils.typing to guard typing imports
pradyunsg Jun 16, 2017
7c5f901
Modify vendoring to include additional .pyi stubs
pradyunsg Jul 4, 2017
adf4538
Add generated stubs
pradyunsg Jul 4, 2017
c2371a1
Exclude the pyi files and extra directory created
pradyunsg Jul 4, 2017
b3e16f9
Fix mypy errors since addition of stubs
pradyunsg Jul 17, 2017
55fd83f
Add a separate tox job for mypy
pradyunsg Jul 17, 2017
6a0da3d
Fix a bug found by mypy
pradyunsg Jul 17, 2017
9b03434
use six instead of try except
pradyunsg Jul 17, 2017
3046f7a
Don't ask for permission
pradyunsg Jul 17, 2017
182c548
Fix remaining errors
pradyunsg Jul 17, 2017
b9b5e4a
:art:
pradyunsg Jul 17, 2017
1b5a23f
:wrench:
pradyunsg Jul 17, 2017
c365304
Merge branch 'master' into mypy/infrastructure
pradyunsg Aug 2, 2017
cb113d5
I actually missed a conflict. Wow.
pradyunsg Aug 2, 2017
11451c5
Merge branch 'master' into mypy/infrastructure
pradyunsg Sep 2, 2017
d37868f
Move the typing file
pradyunsg Sep 2, 2017
d408818
Add imports I'd missed
pradyunsg Sep 2, 2017
d9a4431
Move mypy stubs as well
pradyunsg Sep 2, 2017
efd7264
Update MANIFEST
pradyunsg Sep 2, 2017
ec26f0a
Import from inner packages
pradyunsg Sep 2, 2017
da57810
type: Any partials in cmdoptions
pradyunsg Sep 2, 2017
93d9f20
Remove a useless section
pradyunsg Sep 2, 2017
e2b2f70
isort all imports
pradyunsg Sep 2, 2017
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
Prev Previous commit
Next Next commit
Fix mypy warnings
  • Loading branch information
pradyunsg committed Jul 17, 2017
commit 8f92b5599771f72d310fbde3194fa10bdac82dfd
7 changes: 5 additions & 2 deletions pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@
)


if False:
from typing import Any

# assignment for flake8 to be happy

# This fixes a peculiarity when importing via __import__ - as we are
# initialising the pip module, "from pip import cmdoptions" is recursive
# and appears not to work properly in that situation.
import pip.cmdoptions
cmdoptions = pip.cmdoptions
import pip.cmdoptions # noqa
cmdoptions = pip.cmdoptions # type: Any

# The version as used in the setup.py and the docs conf.py
__version__ = "10.0.0.dev0"
Expand Down
12 changes: 7 additions & 5 deletions pip/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@
from pip.utils.logging import IndentingFormatter
from pip.utils.outdated import pip_version_check

__all__ = ['Command']
if False:
from typing import Optional

__all__ = ['Command']

logger = logging.getLogger(__name__)


class Command(object):
name = None
usage = None
hidden = False
ignore_require_venv = False
name = None # type: Optional[str]
usage = None # type: Optional[str]
hidden = False # type: bool
ignore_require_venv = False # type: bool
log_streams = ("ext://sys.stdout", "ext://sys.stderr")

def __init__(self, isolated=False):
Expand Down
6 changes: 5 additions & 1 deletion pip/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
from pip.commands.uninstall import UninstallCommand
from pip.commands.wheel import WheelCommand

if False:
from typing import List, Type
from pip.basecommand import Command

commands_order = [
InstallCommand,
DownloadCommand,
Expand All @@ -31,7 +35,7 @@
HashCommand,
CompletionCommand,
HelpCommand,
]
] # type: List[Type[Command]]

commands_dict = {c.name: c for c in commands_order}

Expand Down
2 changes: 1 addition & 1 deletion pip/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
from itertools import izip_longest as zip_longest # type: ignore


logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions pip/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import ipaddress
except ImportError:
try:
from pip._vendor import ipaddress
from pip._vendor import ipaddress # type: ignore
except ImportError:
import ipaddr as ipaddress
import ipaddr as ipaddress # type: ignore
ipaddress.ip_address = ipaddress.IPAddress
ipaddress.ip_network = ipaddress.IPNetwork

Expand Down
3 changes: 2 additions & 1 deletion pip/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import sys
import sysconfig
from distutils import sysconfig as distutils_sysconfig
from distutils.command.install import SCHEME_KEYS, install # noqa
from distutils.command.install import SCHEME_KEYS, install # type: ignore

from pip.compat import WINDOWS, expanduser
from pip.utils import appdirs


# Application Directories
USER_CACHE_DIR = appdirs.user_cache_dir("pip")

Expand Down
5 changes: 4 additions & 1 deletion pip/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import logging
import warnings

if False:
from typing import Any


class PipDeprecationWarning(Warning):
pass
Expand All @@ -26,7 +29,7 @@ class RemovedInPip12Warning(PipDeprecationWarning, Pending):
# Warnings <-> Logging Integration


_warnings_showwarning = None
_warnings_showwarning = None # type: Any


def _showwarning(message, category, filename, lineno, file=None, line=None):
Expand Down
2 changes: 1 addition & 1 deletion pip/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
try:
import threading
except ImportError:
import dummy_threading as threading
import dummy_threading as threading # type: ignore


try:
Expand Down
7 changes: 5 additions & 2 deletions pip/utils/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from pip.utils import format_size
from pip.utils.logging import get_indentation

if False:
from typing import Any

try:
from pip._vendor import colorama
# Lots of different errors can come from this, including SystemError and
Expand Down Expand Up @@ -56,7 +59,7 @@ def _select_progress_class(preferred, fallback):
return preferred


_BaseBar = _select_progress_class(IncrementalBar, Bar)
_BaseBar = _select_progress_class(IncrementalBar, Bar) # type: Any


class InterruptibleMixin(object):
Expand Down Expand Up @@ -125,7 +128,7 @@ class BlueEmojiBar(IncrementalBar):
suffix = "%(percent)d%%"
bar_prefix = " "
bar_suffix = " "
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535")
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535") # type: Any


class DownloadProgressMixin(object):
Expand Down
9 changes: 7 additions & 2 deletions pip/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
rmtree, ask_path_exists)


if False:
from typing import Dict, Tuple
from pip.basecommand import Command


__all__ = ['vcs', 'get_src_requirement']


logger = logging.getLogger(__name__)


class VcsSupport(object):
_registry = {}
_registry = {} # type: Dict[str, Command]
schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn']

def __init__(self):
Expand Down Expand Up @@ -98,7 +103,7 @@ class VersionControl(object):
name = ''
dirname = ''
# List of supported schemes for this Version Control
schemes = ()
schemes = () # type: Tuple[str, ...]

def __init__(self, url=None, *args, **kwargs):
self.url = url
Expand Down