Fix editable package filtering logic

Pipfile entry values can be strings; need to check if they actually have a
"get" method before accessing. Also extract the logic into utils.py so it
lives with other functions similar to it.
This commit is contained in:
Tzu-ping Chung
2018-03-21 21:27:40 +08:00
parent 25a2186b0a
commit c8562129de
2 changed files with 19 additions and 14 deletions
+11 -14
View File
@@ -19,16 +19,15 @@ from .utils import (
pep423_name,
recase_file,
find_requirements,
is_editable,
is_file,
is_vcs,
python_version,
cleanup_toml,
is_installable_file,
is_valid_url,
normalize_drive,
python_version,
escape_grouped_arguments,
VCS_LIST,
)
from .environments import (
PIPENV_MAX_DEPTH,
@@ -420,22 +419,20 @@ class Project(object):
@property
def editable_packages(self):
packages = {}
for k, v in self.parsed_pipfile.get('packages', {}).items():
if v.get('editable') and any(
v.get(key) for key in ('file', 'path') + VCS_LIST
):
packages.update({k: v})
packages = {
k: v
for k, v in self.parsed_pipfile.get('packages', {}).items()
if is_editable(v)
}
return packages
@property
def editable_dev_packages(self):
packages = {}
for k, v in self.parsed_pipfile.get('dev-packages', {}).items():
if v.get('editable') and any(
v.get(key) for key in ('file', 'path') + VCS_LIST
):
packages.update({k: v})
packages = {
k: v
for k, v in self.parsed_pipfile.get('dev-packages', {}).items()
if is_editable(v)
}
return packages
@property
+8
View File
@@ -751,6 +751,14 @@ def clean_git_uri(uri):
return uri
def is_editable(pipfile_entry):
if hasattr(pipfile_entry, 'get'):
return pipfile_entry.get('editable', False) and any(
pipfile_entry.get(key) for key in ('file', 'path') + VCS_LIST
)
return False
def is_vcs(pipfile_entry):
import requirements