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
Rely on the init-injection rules to trigger errors for un-depended-on and non-empty __init__.py files #10524
Rely on the init-injection rules to trigger errors for un-depended-on and non-empty __init__.py files #10524
Conversation
So this interacts with setup-py in odd ways, which I've been banging my head against all morning. I need to go clear my head and eat lunch, so will look at this in a bit. I do think that removing the check is the right thing to do. Will write more once I get my thinking cap on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Going to wait for Benjy to review. He realized that we probably shouldn't be erroring on files with content in the first place.
First thought is this: "empty" should also have included "just a namespace package invocation". In both cases it's fine to just grab them without a dep. In the setup-py case, it's actually even necessary to do so: With setup-py, the dist can only export code from libraries that are below it in the source tree, according to the rules in https://www.pantsbuild.org/v2.0/docs/python-setup-py-goal#mapping-libraries-to-distributions. So we have to special-case So, if you have such a situation, you are responsible for your |
752e429
to
940e02b
Compare
Possibly: I think that I don't know enough about them to be sure. But I think that this change might make sense regardless, because it gets out of the way and lets the "automatic injector" rules make that decision and decide whether to error. |
940e02b
to
9f184cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is better behavior and that it makes sense to land regardless of Benjy's changes. Thanks!
9f184cd
to
11742c2
Compare
… & non-empty __init__.py files, and clarify that you need an owning target regardless of inference. [ci skip-rust] [ci skip-build-wheels]
11742c2
to
40dc4b7
Compare
Yes, I think this is a good change, and interacts well with my upcoming change. To clarify my understanding, if |
This change means that—regardless of if there's content in the files or not—we will not infer Currently, your inject init will error if there is already content. Soon, if you stick to your proposal, we won't complain about those inits even if they have content. |
We will pick up the deps of any literal target that owns the |
This is the change I was referring to: #10529 |
Problem
#10517 restored the automatic inclusion of empty
__init__.py
files, and additionally adds an error for "un-depended-on and non-empty__init__.py
files". But--python-infer-inits
also triggered an error for an unowned__init__.py
file, regardless of whether it had content, which meant that if you had inference on, you would see errors from inference before seeing the error that differentiates between empty and non-empty.Solution
Remove the error for un-owned
__init__.py
files from--python-infer-inits
and rely on the error from__init__.py
injection. Additionally, expand the error for__init__.py
injection to clarify that you need an owning target.Result
--python-infer-inits
won't complain about empty__init__.py
files not being owned.[ci skip-rust]
[ci skip-build-wheels]