Implement a --group flag for dependency-group parsing for pip-compile#2175
Implement a --group flag for dependency-group parsing for pip-compile#2175sirosen wants to merge 13 commits intojazzband:mainfrom
--group flag for dependency-group parsing for pip-compile#2175Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Define the option, but don't implement any behavior other than parsing yet. This is defined very similarly to `--group` for `pip` commands, but allows for a double-colon as a delimiter, rather than requiring only one.
Import and adapt the dependency-groups support code from within pip, for use in the pip-compile CLI context.
When parsing `--group` inputs, use a custom type to record the input argument value. This allows the writer to more accurately reproduce the input command as part of the output.
And apply fixes and changes as required. Tests include a simple positive test case and a number of error checking cases for different scenarios. Minor fixes to output are needed and `--group` is treated as an alternative to having a source file when determining whether or not sufficient input options were given.
- New CLI components are rehomed into `piptools._internal._cli` - The `dependency-groups` module is moved to `piptools._internal._dependency_groups` - Usage sites are updated to match
The `pip` parsing for `--group` already uses a single colon for this information. Rather than introducing a second format here, to match other `pip-compile` behaviors, stick to only one format for this information.
`get_metavar` changed in 8.2.0 and has a workaround covered in `click` docs, which is now applied here.
58c7ab2 to
74ce708
Compare
Test behavior on invalid file paths; confirm the error produced. Check handling of multiple and duplicate paths. Confirm treatment of a failure to read the pyproject.toml file.
|
I've rebased, added some missing tests, and added a changelog entry. After the rebase, I also moved some things into I also removed support for I'm going to re-evaluate the treatment of |
|
Okay. I've read back over the I would like to do some exploration of possible refactors to that part of the codebase. I think it's possible to define some kind of input object which is built from That more or less concludes my self-review. I think this is ready.
|
Testing of header generation is extended to support modifying the CLI arguments which are visible to the writer, allowing variable header generation tests.
Resolves #2062 1
This is an initial proposed implementation, but even after finishing it, I have two major outstanding questions.
Q1: Should
--groupbe considered a source file?I didn't merge parsed
--groupinputs intosrc_files, but I did countlen(src_files) + len(groups)in a couple of contexts to make it behave similarly.I'm not sure if this was the right approach, or if I missed or misunderstood the goals of the
src_fileschecking in any way.Extra attention in this area during review would be appreciated -- as a new contributor, I did my best to follow the existing code and keep the changes small, but may have made mistakes.
Q2: What tests are missing?
The initial tests are pretty simple and limited. Probably, more tests would be worthwhile, but it's hard to tell what cases would be useful vs redundant with existing tests.
What additional checks seem important?
Note: Accepts
pyproject.toml:Xandpyproject.toml::XUpdate: This was removed from the PR!
Although supporting
::and:side-by-side is easy from the perspective of maintenance and support, after plenty of time to think about this, I decided that it provides a worse experience for users. It's different frompip install --groupand doesn't have a strong enough justification for that difference.I decided on this after weighing the options from #2062 and would be willing to adjust if there's a strong objection, but think this is the best approach.pip-compilecan have its own syntax, but accepting thepip installsyntax is an easy gain for compatibility.Because the filename part is already optional, the behavior which handles output of options also naturally handles the:vs::variation.Commits
--grouptopip-compileoptionsChecklists
Contributor checklist
Maintainer checklist
backwards incompatible,feature,enhancement,deprecation,bug,dependency,docsorskip-changelogas they determine changelog listing.Footnotes
Aside: sorry it took so long to submit a PR! This has been on my to-do list for a while. ↩