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

Remove @rule Select syntax #7477

Merged
merged 4 commits into from Apr 2, 2019

Conversation

Projects
None yet
5 participants
@stuhood
Copy link
Member

commented Apr 2, 2019

Problem

The Select syntax in @rule declarations used to differentiate the declarative parameter selectors, but with the advent of coroutine @rules and removal of TypeConstraint, the Select syntax no longer has any use.

Solution

Remove the Select syntax for @rules, while preserving it as the marker for root selections in the graph. Update the documentation for @rules to refer to these as "parameter selectors".

@stuhood stuhood requested review from illicitonion, ity and cosmicexplorer Apr 2, 2019

@cosmicexplorer
Copy link
Contributor

left a comment

Thanks so much for doing the work to make this change across the codebase and to update the docs! I really, really like the way declaring @rules looks like now!!

(`Select(IntType)`), this `@rule` represents a conversion from `IntType` to `StrType`, with no
second argument is a list of parameter selectors that declare the types of the input parameters for
the `@rule`. In this case, because the Product type is `StringType` and there is one parameter
selector (for `IntType`), this `@rule` represents a conversion from `IntType` to `StrType`, with no

This comment has been minimized.

Copy link
@cosmicexplorer

cosmicexplorer Apr 2, 2019

Contributor

"parameter selectors" is a very good edit, this leaves the opportunity to expand it later as needed while making it extremely clear what those types are doing there.

Show resolved Hide resolved src/python/pants/engine/rules.py Outdated
@Eric-Arellano
Copy link
Contributor

left a comment

Cool! This is a much nicer syntax.

@illicitonion
Copy link
Contributor

left a comment

This is a great clean-up, thanks!

pub fn select_str(select: &Select) -> String {
format!("Select({})", select.product).to_string() // TODO variant key
pub fn select_root_str(select: &Select) -> String {
format!("Select({})", select.product)

This comment has been minimized.

Copy link
@illicitonion

illicitonion Apr 2, 2019

Contributor

Should we rename Select to Root or SelectRoot or something here, now that that's what it represents?

This comment has been minimized.

Copy link
@stuhood

stuhood Apr 2, 2019

Author Member

"It's complicated", because Select is still the Node that we run to kick off a request for the parameters to a rule that is going to run, and in that case it isn't a root.

@stuhood stuhood merged commit 76415e5 into pantsbuild:master Apr 2, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@stuhood stuhood deleted the twitter:stuhood/remove-select branch Apr 2, 2019

@ity

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2019

nice change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.