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

Refactor find_valid_field_sets. #10732

Merged
merged 3 commits into from
Sep 4, 2020

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Sep 4, 2020

  • Now it's possible to get the FieldSets that subclass some
    given superclass for any arbitrary set of targets.
  • The previous logic, that applies this specifically to the
    target roots, now uses this new logic.
  • Removes FieldSetWithOrigin, which was unused,
    and would have complicated the refactoring.
  • Also improves error messages in setup_py.py, that
    are unrelated to this change but didn't merit their
    own change.

[ci skip-rust]

[ci skip-build-wheels]

- Now it's possible to get the FieldSets that subclass some
  given superclass for any arbitrary set of targets.
- The previous logic, that applies this to the target roots,
  now uses this new logic.
- Also removes FieldSetWithOrigin, which was unused,
  and would have complicated the refactoring.
- Also improves error messages in setup_py.py, that
  are unrelated to this change but didn't merit their
  own change.

[ci skip-rust]

[ci skip-build-wheels]
f"Exporting owners for {target.address} are "
f"ambiguous. Found {exported_ancestor.address} and "
f"{len(sibling_owners)} others: "
f"python_distribution target owning {target.address} is ambiguous. "
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't technically know it's a python_distribution. This would be misleading with subclasses. You could call target.alias instead.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

target.alias is the alias of the target whose owner we're seeking, which is typically a python_library. The owner is a python_distribution (or, technically, a subclass, true, but I would rather sacrifice a tiny bit of accuracy in the general case for clarity in the usual case).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call exported_ancestor.alias?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

Maybe, but what if the siblings aren't of this type? And anyway, this is a pretty rare corner case. Doesn't seem worth the worry.

src/python/pants/backend/python/goals/setup_py.py Outdated Show resolved Hide resolved
src/python/pants/engine/target.py Show resolved Hide resolved
src/python/pants/engine/target.py Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Sep 4, 2020

Coverage Status

Coverage remained the same at 0.0% when pulling a1ec666 on benjyw:remove_field_set_with_origin into 5886865 on pantsbuild:master.

[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]
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.

Thanks!


def __init__(self, msg: str):
super().__init__(
f"{msg} See https://www.pantsbuild.org/v2.0/docs/python-setup-py-goal for "
Copy link
Contributor

Choose a reason for hiding this comment

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

This is likely to become stale. But it's fine given the nature of 2.0.

We'll want to audit for the string "v2.0" as soon as we switch the default version of the docs.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

Yeah, there is some general tooling we'll need to build around the docs (e.g., finding broken links). Basic stuff that readme.com doesn't provide yet.

@benjyw benjyw merged commit 91921db into pantsbuild:master Sep 4, 2020
@benjyw benjyw deleted the remove_field_set_with_origin branch September 4, 2020 06:00
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.

None yet

3 participants