Skip to content
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: add export flag to list command #3780

Merged
merged 6 commits into from
Feb 4, 2025
Merged

Conversation

SandrineP
Copy link
Collaborator

Adds one of the missing sub-command #3535

@SandrineP SandrineP added the release::enhancements For enhancements PRs or implementing features label Jan 30, 2025
@SandrineP SandrineP marked this pull request as ready for review February 4, 2025 09:25
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments.

You might want to merge / rebase main because #3793 has been merged in the meantime to fix the failing CI checks on Windows.

@@ -218,7 +219,11 @@ namespace mamba
{
if (options.canonical)
{
LOG_WARNING << "Option --canonical ignored because of --explicit";
LOG_WARNING << "Option --canonical ignored because of --explicit \n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG_* add new lines implicitly.

Suggested change
LOG_WARNING << "Option --canonical ignored because of --explicit \n";
LOG_WARNING << "Option --canonical ignored because of --explicit";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this message might be slightly more explicit.

Suggested change
LOG_WARNING << "Option --canonical ignored because of --explicit \n";
LOG_WARNING << "Option --canonical ignored because --explicit was provided";

}
if (options.export_)
{
LOG_WARNING << "Option --export ignored because of --explicit \n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_WARNING << "Option --export ignored because of --explicit \n";
LOG_WARNING << "Option --export ignored because of --explicit";

@@ -234,12 +239,23 @@ namespace mamba
}
else if (options.canonical)
{
if (options.export_)
{
LOG_WARNING << "Option --export ignored because of --explicit \n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste mistake?

Suggested change
LOG_WARNING << "Option --export ignored because of --explicit \n";
LOG_WARNING << "Option --export ignored because of --canonical";

Comment on lines 120 to 127
else:
if canonical_flag == "--canonical":
if canonical_flag in ["-c", "--canonical"]:
items = ["conda-forge/", "::"]
for output in outputs_list:
assert all(i in output for i in items)
assert " " not in output
else:
if export_flag in ["-e", "--export"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use elif twice instead here.

Comment on lines 111 to 112
outputs_list = [i for i in outputs_list if not i.startswith("Warning")]
outputs_list = [i for i in outputs_list if i != ""]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outputs_list = [i for i in outputs_list if not i.startswith("Warning")]
outputs_list = [i for i in outputs_list if i != ""]
outputs_list = [i for i in outputs_list if i != "" and not i.startswith("Warning")]

Comment on lines 128 to 130
items = ["conda-forge/", "::", " "]
for output in outputs_list:
# assert all(i not in output for i in items)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
items = ["conda-forge/", "::", " "]
for output in outputs_list:
# assert all(i not in output for i in items)
items = ["conda-forge/", "::", " "]
for output in outputs_list:
assert all(i not in output for i in items)

Also you might want to define items only once before the first if.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or alternatively:

Suggested change
items = ["conda-forge/", "::", " "]
for output in outputs_list:
# assert all(i not in output for i in items)
for output in outputs_list:

Configurable("export", false)
.group("cli")
.description(
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical."
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical is also provided."

items = ["conda-forge/", "::", " "]
for output in outputs_list:
# assert all(i not in output for i in items)
assert output.count("=") == 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly more stricter.

Suggested change
assert output.count("=") == 2
assert len(output.split("=")) == 3

@jjerphan jjerphan merged commit b5e197f into mamba-org:main Feb 4, 2025
34 checks passed
SandrineP added a commit to SandrineP/mamba that referenced this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release::enhancements For enhancements PRs or implementing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants