-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(poetrylock): support extracting groups from v2+ poetry.lock
files
#376
base: main
Are you sure you want to change the base?
Conversation
7d549ec
to
340f76b
Compare
@@ -65,6 +66,28 @@ func (e Extractor) FileRequired(api filesystem.FileAPI) bool { | |||
return filepath.Base(api.Path()) == "poetry.lock" | |||
} | |||
|
|||
func resolveGroups(pkg poetryLockPackage) []string { | |||
// by definition an optional package cannot be in any other group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on how optional works here, does this refer to this? https://python-poetry.org/docs/managing-dependencies/#optional-groups or are optional groups and optional packages different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
umm ok I didn't know about that - I believe it was referring to https://python-poetry.org/docs/pyproject/#optional-dependencies but I'll check what happens when using these optional groups.
fwiw right now "optional" logically is focused on "is the optional
property set to true
" - so I know that optional-dependencies
is one way of having that property come out as true
, and now the question is if "optional groups" result in that too or something different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like "optional groups" just manage what gets installed by default when you run poetry install
, so they don't have any bearing on the lockfile itself, which makes sense
Poetry v2 lockfiles now include the groups a package belongs to, meaning that we can support extracting them to allow filtering.
Similar to Maven and NPM, Poetry explicitly notes everything that isn't in an explicit group as being in the
main
group meaning for packages that are considered in that group we always use an empty slice instead since that's how we indicate the "production" group.I generated the final fixture using the following
pyproject.toml
:Technically we don't need the
python_version
constraint onproto-plus
for this feature, but I realised we don't have any existing fixtures for this situation so I figured I'd sneak it in as part of this given it seems like we already support the lockfile having a package multiple names with different versionsThis is a sister PR to google/osv-scanner#1477 since
osv-scanner
is still in the middle of transitioning to usingosv-scalibr
- the core logic is exactly the same, and either (or both) should be fine to land