Skip to content

Commit

Permalink
Merge pull request #4545 from pradyunsg/mypy/infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Sep 4, 2017
2 parents cd9ecdf + e2b2f70 commit 28cca11
Show file tree
Hide file tree
Showing 42 changed files with 316 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pip.egg-info/
MANIFEST
.tox
.cache
.mypy_cache
*.egg
*.eggs
*.py[cod]
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ matrix:
- env: TOXENV=docs
- env: TOXENV=lint-py2
- env: TOXENV=lint-py3
- env: TOXENV=mypy
- env: TOXENV=packaging
# PyPy jobs start first -- they are the slowest
- env: TOXENV=pypy
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ exclude appveyor.yml
recursive-include src/pip/_vendor *.pem
recursive-include docs Makefile *.rst *.py *.bat

exclude src/pip/_vendor/six
recursive-exclude src/pip/_vendor *.pyi

prune .github
prune .travis
prune docs/_build
Expand Down
1 change: 1 addition & 0 deletions news/4545.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integrate with mypy for utilizing static typing.
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ known_first_party =
default_section = THIRDPARTY

[flake8]
# Ignoring unused imports since mypy would warn of that.
ignore = F401
exclude = .tox,.idea,*.egg,build,_vendor,data
select = E,W,F

[mypy]
follow_imports = silent
ignore_missing_imports = True

[mypy-pip/_vendor/*]
follow_imports = skip
ignore_errors = True

[tool:pytest]
addopts = --ignore src/pip/_vendor --ignore tests/tests_cache

Expand Down
11 changes: 1 addition & 10 deletions src/pip/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
InsecureRequestWarning,
)


# 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._internal.cmdoptions
# cmdoptions = pip._internal.cmdoptions

logger = logging.getLogger(__name__)

# Hide the InsecureRequestWarning from urllib3
Expand Down Expand Up @@ -241,7 +232,7 @@ def main(args=None):
sys.exit(1)

# Needed for locale.getpreferredencoding(False) to work
# in pip.utils.encoding.auto_decode
# in pip._internal.utils.encoding.auto_decode
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error as e:
Expand Down
16 changes: 10 additions & 6 deletions src/pip/_internal/basecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
)
from pip._internal.index import PackageFinder
from pip._internal.locations import running_under_virtualenv
from pip._internal.req import InstallRequirement, parse_requirements
from pip._internal.req.req_file import parse_requirements
from pip._internal.req.req_install import InstallRequirement
from pip._internal.status_codes import (
ERROR, PREVIOUS_BUILD_DIR_ERROR, SUCCESS, UNKNOWN_ERROR,
VIRTUALENV_NOT_FOUND
Expand All @@ -29,18 +30,21 @@
from pip._internal.utils.logging import IndentingFormatter
from pip._internal.utils.misc import get_prog, normalize_path
from pip._internal.utils.outdated import pip_version_check
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

__all__ = ['Command']
if MYPY_CHECK_RUNNING:
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

0 comments on commit 28cca11

Please sign in to comment.