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

Pants internally uses dedicated Sources and Dependencies fields #16037

Merged
merged 5 commits into from
Jul 5, 2022

Conversation

thejcannon
Copy link
Member

Fixes #15727. Note there's an auto-use fixture now which validates the convention. This is easier than a flake8 plugin.

[ci skip-rust]

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]
@@ -42,3 +44,35 @@ def pytest_sessionfinish(session) -> None:
# Technically unecessary, but nice if people are running tests directly from repo
# (not using pants).
namespace_init_path.unlink()


@pytest.fixture(autouse=True, scope="session")
Copy link
Contributor

Choose a reason for hiding this comment

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

This code should be fast enough, but it is worth noting we're being bit here by an issue our users have often brought up: scope is effectively impotent in the face of the way we run tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, I just didn't want it firing for every test case when we could do better 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

Also scope isn't impotent. Session scope is though. The other scopes are legitimate

Copy link
Contributor

Choose a reason for hiding this comment

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

Would an __init_subclass__ production runtime check be "better"? That would also loop in 3rdparty plugin authors.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it, but decided to scope this to just our repo for now. I'd honestly approve that PR though.
We should be intentional though, so this is a good first step.

[ci skip-rust]

[ci skip-build-wheels]
[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
Member

@kaos kaos left a comment

Choose a reason for hiding this comment

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

lgtm :)

src/python/pants/conftest.py Show resolved Hide resolved
# 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 changed the title Use dedicated Dependencies fields Use dedicated Sources and Dependencies fields Jul 5, 2022
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 think this is good as an "internal only change" -- it is not a Plugin API change. PR label should be updated imo.

I would be more concerned if it was a Plugin API change because it goes against our instructions in Target API Concepts, where we explain often there's zero need to subclass.

@thejcannon
Copy link
Member Author

I marked it as such because can update their plugins to use more specific types if they so choose.

@thejcannon
Copy link
Member Author

It is a nonbreaking plugin API change IMO

@Eric-Arellano
Copy link
Contributor

Okay, then maybe rename to "Pants internally uses dedicated Sources and Dependencies fields"

@thejcannon thejcannon changed the title Use dedicated Sources and Dependencies fields Pants internally uses dedicated Sources and Dependencies fields Jul 5, 2022
@thejcannon thejcannon merged commit dd53026 into pantsbuild:main Jul 5, 2022
@thejcannon thejcannon deleted the depsfield branch July 5, 2022 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit and fix instances of using the generic Dependencies field when declaring a target
4 participants