Skip to content

Commit ea7c3fe

Browse files
committed
Add typing and tests
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 2e63581 commit ea7c3fe

6 files changed

Lines changed: 368 additions & 50 deletions

File tree

src/_packagedcode/pypi.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import ast
1212
from configparser import ConfigParser
13+
import copy
1314
import json
1415
import logging
1516
from pathlib import Path
@@ -972,6 +973,23 @@ def get_requirements_txt_dependencies(location, include_nested=False):
972973
return dependent_packages, extra_data
973974

974975

976+
def can_process_dependent_package(dep: models.DependentPackage):
977+
"""
978+
Return True if we can process the dependent package
979+
typically anything that's not a plain standard specifier
980+
can not be processed such as an editable requirement
981+
"""
982+
# copying dep.extra_data to avoid mutating the original
983+
requirement_flags = copy.copy(dep.extra_data) or {}
984+
requirement_flags.pop("hash_options", None)
985+
if not requirement_flags:
986+
return True
987+
# we can not process the requirement if it has any flag set
988+
# because this means it is not a standard specifier
989+
# but rather some pip specific option of sorts
990+
return not any(requirement_flags.values())
991+
992+
975993
def get_attribute(metainfo, name, multiple=False):
976994
"""
977995
Return the value for the attribute ``name`` in the ``metainfo`` mapping,

0 commit comments

Comments
 (0)