mirror of https://github.com/pypa/pip
Merge pull request #8292 from deveshks/add-mypy-req-constructors
This commit is contained in:
commit
c3203aa282
|
@ -8,9 +8,6 @@ These are meant to be used elsewhere within pip to create instances of
|
|||
InstallRequirement.
|
||||
"""
|
||||
|
||||
# The following comment should be removed at some point in the future.
|
||||
# mypy: strict-optional=False
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
@ -78,7 +75,7 @@ def convert_extras(extras):
|
|||
|
||||
|
||||
def parse_editable(editable_req):
|
||||
# type: (str) -> Tuple[Optional[str], str, Optional[Set[str]]]
|
||||
# type: (str) -> Tuple[Optional[str], str, Set[str]]
|
||||
"""Parses an editable requirement into:
|
||||
- a requirement name
|
||||
- an URL
|
||||
|
@ -120,7 +117,7 @@ def parse_editable(editable_req):
|
|||
Requirement("placeholder" + extras.lower()).extras,
|
||||
)
|
||||
else:
|
||||
return package_name, url_no_extras, None
|
||||
return package_name, url_no_extras, set()
|
||||
|
||||
for version_control in vcs:
|
||||
if url.lower().startswith('{}:'.format(version_control)):
|
||||
|
@ -149,7 +146,7 @@ def parse_editable(editable_req):
|
|||
"Could not detect requirement name for '{}', please specify one "
|
||||
"with #egg=your_package_name".format(editable_req)
|
||||
)
|
||||
return package_name, url, None
|
||||
return package_name, url, set()
|
||||
|
||||
|
||||
def deduce_helpful_msg(req):
|
||||
|
@ -264,7 +261,7 @@ def _looks_like_path(name):
|
|||
|
||||
|
||||
def _get_url_from_path(path, name):
|
||||
# type: (str, str) -> str
|
||||
# type: (str, str) -> Optional[str]
|
||||
"""
|
||||
First, it checks whether a provided path is an installable directory
|
||||
(e.g. it has a setup.py). If it is, returns the path.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# The following comment should be removed at some point in the future.
|
||||
# mypy: strict-optional=False
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
@ -122,7 +119,8 @@ class RequirementSet(object):
|
|||
return [install_req], None
|
||||
|
||||
try:
|
||||
existing_req = self.get_requirement(install_req.name)
|
||||
existing_req = self.get_requirement(
|
||||
install_req.name) # type: Optional[InstallRequirement]
|
||||
except KeyError:
|
||||
existing_req = None
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# The following comment should be removed at some point in the future.
|
||||
# mypy: strict-optional=False
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import contextlib
|
||||
|
@ -98,6 +95,7 @@ class RequirementTracker(object):
|
|||
"""Add an InstallRequirement to build tracking.
|
||||
"""
|
||||
|
||||
assert req.link
|
||||
# Get the file to write information about this requirement.
|
||||
entry_path = self._entry_path(req.link)
|
||||
|
||||
|
@ -130,6 +128,7 @@ class RequirementTracker(object):
|
|||
"""Remove an InstallRequirement from build tracking.
|
||||
"""
|
||||
|
||||
assert req.link
|
||||
# Delete the created file and the corresponding entries.
|
||||
os.unlink(self._entry_path(req.link))
|
||||
self._entries.remove(req)
|
||||
|
|
|
@ -583,10 +583,10 @@ def test_parse_editable_local(
|
|||
exists_mock.return_value = isdir_mock.return_value = True
|
||||
# mocks needed to support path operations on windows tests
|
||||
abspath_mock.return_value = "/some/path"
|
||||
assert parse_editable('.') == (None, 'file:///some/path', None)
|
||||
assert parse_editable('.') == (None, 'file:///some/path', set())
|
||||
abspath_mock.return_value = "/some/path/foo"
|
||||
assert parse_editable('foo') == (
|
||||
None, 'file:///some/path/foo', None,
|
||||
None, 'file:///some/path/foo', set(),
|
||||
)
|
||||
|
||||
|
||||
|
@ -594,7 +594,7 @@ def test_parse_editable_explicit_vcs():
|
|||
assert parse_editable('svn+https://foo#egg=foo') == (
|
||||
'foo',
|
||||
'svn+https://foo#egg=foo',
|
||||
None,
|
||||
set(),
|
||||
)
|
||||
|
||||
|
||||
|
@ -602,7 +602,7 @@ def test_parse_editable_vcs_extras():
|
|||
assert parse_editable('svn+https://foo#egg=foo[extras]') == (
|
||||
'foo[extras]',
|
||||
'svn+https://foo#egg=foo[extras]',
|
||||
None,
|
||||
set(),
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue