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

Allow for attribute lookup in rule parsing #16948

Merged
merged 1 commit into from
Sep 22, 2022

Conversation

thejcannon
Copy link
Member

Fixes #16868.

[ci skip-rust]
[ci skip-build-wheels]

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@thejcannon thejcannon added the category:internal CI, fixes for not-yet-released features, etc. label Sep 21, 2022
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

I'm not following what happens with Get(Output, MyType.create()), which should be Get(Output, MyType, MyType.create())? That problem kept popping up that people (including me) accidentally wrote it the shorthand way, so we added the nice error message.

Comment on lines -114 to -118
raise parse_error(
f"Because you are using the shorthand form {call_node.func.id}(OutputType, "
"InputType(constructor args)), the second argument should be a top-level "
"constructor function call, like `MergeDigest(...)` or `Process(...)`, rather "
"than a method call."
Copy link
Member Author

Choose a reason for hiding this comment

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

These error messages get worse, but 🤷‍♂️ It'll still list the incorrect value and file/line.

@thejcannon
Copy link
Member Author

I'm not following what happens with Get(Output, MyType.create()), which should be Get(Output, MyType, MyType.create())? That problem kept popping up that people (including me) accidentally wrote it the shorthand way, so we added the nice error message.

You'll get the error complaining how it expected a type.

ValueError: Expected a `type`, but got: <bound method MyType.create of <class 'path.to.MyType'>> (type `method`) in /path/to/file.py:513

@thejcannon
Copy link
Member Author

@Eric-Arellano gonna submit, LMK if you think the error is unacceptable and we can fix.

@thejcannon thejcannon merged commit c64579c into pantsbuild:main Sep 22, 2022
@thejcannon thejcannon deleted the 16868 branch September 22, 2022 18:17
@Eric-Arellano
Copy link
Contributor

LG, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rule parser doesn't handle attribute arguments
3 participants