Skip to content

Commit

Permalink
inspection: ad each extra package as a dependency
Browse files Browse the repository at this point in the history
Resolves: #3129
  • Loading branch information
abn authored and finswimmer committed Oct 13, 2020
1 parent 655c5d3 commit 38fddf0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def to_package(
package.requires = poetry_package.requires
return package

seen_requirements = set()

for req in self.requires_dist or []:
try:
# Attempt to parse the PEP-508 requirement string
Expand All @@ -191,8 +193,11 @@ def to_package(

package.extras[extra].append(dependency)

if dependency not in package.requires:
req = dependency.to_pep_508(with_extras=True)

if req not in seen_requirements:
package.requires.append(dependency)
seen_requirements.add(req)

return package

Expand Down
4 changes: 2 additions & 2 deletions tests/repositories/test_legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_get_package_information_skips_dependencies_with_invalid_constraints():
package.description == "Python Language Server for the Language Server Protocol"
)

assert 19 == len(package.requires)
assert 25 == len(package.requires)
assert sorted(
[r for r in package.requires if not r.is_optional()], key=lambda r: r.name
) == [
Expand Down Expand Up @@ -216,7 +216,7 @@ def test_get_package_from_both_py2_and_py3_specific_wheels():
assert "ipython" == package.name
assert "5.7.0" == package.version.text
assert "*" == package.python_versions
assert 26 == len(package.requires)
assert 41 == len(package.requires)

expected = [
Dependency("appnope", "*"),
Expand Down
2 changes: 1 addition & 1 deletion tests/repositories/test_pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_pypi_repository_supports_reading_bz2_files():
package = repo.package("twisted", "18.9.0")

assert package.name == "twisted"
assert 28 == len(package.requires)
assert 71 == len(package.requires)
assert sorted(
[r for r in package.requires if not r.is_optional()], key=lambda r: r.name
) == [
Expand Down

0 comments on commit 38fddf0

Please sign in to comment.