Skip to content

Commit

Permalink
always check extras and make it an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Grubenmann committed Jan 8, 2023
1 parent b5118ac commit 017df47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
30 changes: 15 additions & 15 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,21 +409,21 @@ def validate(
'Use "allow-prereleases" instead.'
)

if "extras" in config:
for extra_name, requirements in config["extras"].items():
extra_name = canonicalize_name(extra_name)

for req in requirements:
req_name = canonicalize_name(req)
for dependency in config["dependencies"].keys():
dep_name = canonicalize_name(dependency)
if req_name == dep_name:
break
else:
result["warnings"].append(
f'Cannot find dependency "{req}" for extra '
f'"{extra_name}" in main dependencies.'
)
if "extras" in config:
for extra_name, requirements in config["extras"].items():
extra_name = canonicalize_name(extra_name)

for req in requirements:
req_name = canonicalize_name(req)
for dependency in config.get("dependencies", {}).keys():
dep_name = canonicalize_name(dependency)
if req_name == dep_name:
break
else:
result["errors"].append(
f'Cannot find dependency "{req}" for extra '
f'"{extra_name}" in main dependencies.'
)

# Checking for scripts with extras
if "scripts" in config:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ def test_validate_strict_fails_strict_and_non_strict() -> None:
"'version' is a required property",
"'description' is a required property",
"'authors' is a required property",
(
'Cannot find dependency "missing_extra" for extra "some-extras" in '
"main dependencies."
),
(
'Cannot find dependency "another_missing_extra" for extra '
'"some-extras" in main dependencies.'
),
(
'Script "a_script_with_unknown_extra" requires extra "foo" which is not'
" defined."
Expand All @@ -250,14 +258,6 @@ def test_validate_strict_fails_strict_and_non_strict() -> None:
'The "pathlib2" dependency specifies the "allows-prereleases" property,'
' which is deprecated. Use "allow-prereleases" instead.'
),
(
'Cannot find dependency "missing_extra" for extra "some-extras" in '
"main dependencies."
),
(
'Cannot find dependency "another_missing_extra" for extra '
'"some-extras" in main dependencies.'
),
],
}

Expand Down

0 comments on commit 017df47

Please sign in to comment.