[ANE-2877] Support PEP 621 project.dependencies in Poetry 2.x strategy#1683
[ANE-2877] Support PEP 621 project.dependencies in Poetry 2.x strategy#1683
Conversation
Poetry 2.x introduced PEP 621 support, allowing production dependencies to be declared in the project.dependencies section instead of the legacy tool.poetry.dependencies. The Poetry strategy only read the latter, causing production deps to be missed for Poetry 2.x projects using the standard format. Changes: - allPoetryProductionDeps now merges PEP 621 deps with legacy Poetry deps (legacy takes precedence for dedup) - pyProjectDeps includes PEP 621 deps as production in the no-lock-file path - Extract reqName to shared Util module (used by both Poetry and PDM) - Add test fixtures and tests for PEP 621 and mixed-format projects Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WalkthroughThe change adds support for detecting PEP 621 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Strategy/Python/Util.hs`:
- Around line 178-180: The functions depName and reqName duplicate the same
logic; remove the duplicate by consolidating them: either export the existing
depName as the public API and delete reqName, or make depName a local alias to
reqName (or vice‑versa) so only one implementation remains. Update any
references to use the retained symbol (depName or reqName) and adjust the module
exports accordingly to avoid duplication while preserving external API.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: c025a036-747d-47d6-8f70-9691f319f758
📒 Files selected for processing (8)
Changelog.mdsrc/Strategy/Python/PDM/PdmLock.hssrc/Strategy/Python/Poetry/Common.hssrc/Strategy/Python/Poetry/PyProject.hssrc/Strategy/Python/Util.hstest/Python/Poetry/CommonSpec.hstest/Python/Poetry/testdata/pep621-mixed/pyproject.tomltest/Python/Poetry/testdata/pep621/pyproject.toml
| reqName :: Req -> Text | ||
| reqName (NameReq name _ _ _) = name | ||
| reqName (UrlReq name _ _ _) = name |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider consolidating with existing depName function.
The new reqName function (lines 178-180) has identical implementation to the existing depName function (lines 40-42):
-- depName at lines 40-42:
depName :: Req -> Text
depName (NameReq nm _ _ _) = nm
depName (UrlReq nm _ _ _) = nm
-- reqName at lines 178-180:
reqName :: Req -> Text
reqName (NameReq name _ _ _) = name
reqName (UrlReq name _ _ _) = nameConsider either:
- Exporting
depNameinstead of introducingreqName, or - Keeping
reqNameas the public API and makingdepNamea local alias
This would eliminate code duplication within the same module.
♻️ Proposed refactor
module Strategy.Python.Util (
buildGraph,
buildGraphSetupFile,
Version (..),
Marker (..),
MarkerOp (..),
Operator (..),
Req (..),
- reqName,
+ reqName, -- exported name
requirementParser,
reqToDependency,
toConstraint,
) where
...
-depName :: Req -> Text
-depName (NameReq nm _ _ _) = nm
-depName (UrlReq nm _ _ _) = nm
+-- | Extract the package name from a Req.
+reqName :: Req -> Text
+reqName (NameReq nm _ _ _) = nm
+reqName (UrlReq nm _ _ _) = nm
+
+-- | Alias for reqName, used internally.
+depName :: Req -> Text
+depName = reqName
...
--- Remove the duplicate definition at lines 178-180
-reqName :: Req -> Text
-reqName (NameReq name _ _ _) = name
-reqName (UrlReq name _ _ _) = name🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Strategy/Python/Util.hs` around lines 178 - 180, The functions depName
and reqName duplicate the same logic; remove the duplicate by consolidating
them: either export the existing depName as the public API and delete reqName,
or make depName a local alias to reqName (or vice‑versa) so only one
implementation remains. Update any references to use the retained symbol
(depName or reqName) and adjust the module exports accordingly to avoid
duplication while preserving external API.
CodeRabbit caught that depName and reqName had identical implementations in the same module. Removed depName and updated its two internal usages to use reqName instead. reqName is the more accurate name since it operates on Req values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Overview
Poetry 2.x introduced PEP 621 support, allowing production dependencies to be declared in
[project].dependenciesinstead of legacy[tool.poetry.dependencies]. The Poetry strategy only read the latter, so projects using PEP 621 had their production deps missed entirely.The
[project]section was already parsed intoPyProjectMetadatabut never consumed by the Poetry strategy. This PR wires it into both the lock-file and no-lock-file paths while preserving full backward compatibility.Key changes:
allPoetryProductionDepsmerges PEP 621 deps with legacy Poetry deps (legacy wins on dedup)pyProjectDepsincludes PEP 621 deps as production in the no-lock-file pathreqNamehelper extracted toStrategy.Python.Util(previously duplicated in PDM)Acceptance criteria
[project].dependencieshave production deps detected[tool.poetry.dependencies]projects continue to work unchangedTesting plan
allPoetryProductionDepsRisks
Minimal -- additive change. Legacy behavior is unchanged; PEP 621 deps are merged via
Map.unionwith legacy entries taking precedence.Metrics
N/A
References
Checklist
docs/.Changelog.md. If this PR did not mark a release, I added my changes into an## Unreleasedsection at the top..fossa.ymlorfossa-deps.{json.yml}, I updateddocs/references/files/*.schema.jsonAND I have updated example files used byfossa initcommand.docs/references/subcommands/<subcommand>.md.