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

Restore support for dependencies outputting 3rdparty deps through new enum option #8960

Merged
merged 2 commits into from
Jan 22, 2020

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Jan 14, 2020

Turns out, there is a use case for ./pants dependencies --external-only, such as scripts using it to determine the exact version strings of Python requirements used by Pants targets.

However, the option names are not ideal, such as having to enforce that they're mutually exclusive at runtime. It's also a bit confusing to default to internal and external. Ideally, we'd default to sources (aka internal) and only include 3rdparty (aka external) when requested.

We can make both improvements through a new enum option, which wasn't available when we first wrote this due to Python 2 not having enums.

help message for the dependencies2 goal

@@ -20,10 +27,16 @@ def register_options(cls, register):
super().register_options(register)
register(
'--transitive',
default=True,
default=False,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The V1 task will change its default to False in 1.27.0.dev0. I changed this one now to make sure we don't forget to also update the V2 implementation.

lambda: not self.is_external_only and not self.is_internal_only,
removal_version="1.26.0.dev0",
lambda: opts.is_default("type") and not opts.internal_only and not opts.external_only,
removal_version="1.27.0.dev0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I bumped these up one major version because Stu mentioned in a different PR that that's a good practice when we deprecate the prior solution to a deprecation that's still in flight.

type=bool,
help='Run dependencies against transitive dependencies of targets specified on the command line.',
)
# TODO(#8762): Wire this up. Currently we only support `internal`.
register(
'--type', type=DependencyType, default=DependencyType.INTERNAL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very open to suggestions for a better name. I couldn't think of anything more natural and generally like this, except that type is an overloaded word.

@Eric-Arellano Eric-Arellano mentioned this pull request Jan 16, 2020
Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Works for me, but I don't love the naming...

@@ -11,6 +12,12 @@
from pants.engine.selectors import Get


class DependencyType(Enum):
INTERNAL = "internal"
Copy link
Contributor

Choose a reason for hiding this comment

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

Internal and external are really unclear names to me, and I didn't know what they meant until I read your helptext on the flag. How would you feel about source and 3rdparty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great recommendations! Thank you!

@Eric-Arellano Eric-Arellano changed the title Restore support for dependencies outputting external deps through new enum option Restore support for dependencies outputting 3rdparty deps through new enum option Jan 22, 2020
@Eric-Arellano Eric-Arellano merged commit 188e5d1 into pantsbuild:master Jan 22, 2020
@Eric-Arellano Eric-Arellano deleted the dependencies-external branch January 22, 2020 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants