-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Add --unowned-dependency-behavior option for Python #13491
Conversation
I'll try and add some unit tests soon. Local testing shows it works! 🎉 |
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
_STDLIB_MODULES = [ |
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.
Are there any modules that were removed from previous versions and might not appear? 🤔
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.
@Eric-Arellano will likely have thoughts on this. We actually... removed per-interpreter-version lists a while back in #12818. But that was because we were using it to filter things, rather than to backstop a validation like this one.
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.
Yeah I think this is an ever-growing list unless there's a good reason why it shouldn't be.
My question here is basically I just dumped the std library list form 3.10 because it was easy, so is there anything that needs to be added because 3.10 doesn't have them (anymore).
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.
Looks great! Thanks a lot.
register( | ||
"--unowned-dependency-behavior", | ||
type=UnownedDependencyUsage, | ||
default=UnownedDependencyUsage.DoNothing, |
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.
This is a good+safe initial default, but I'm very interested in how many false positives you get with this... if we're able to make it warn by default in a future release, that would be great.
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.
Agreed! Will report back later on our monorepo
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.
So far it's just found a bunch of questionable imports, things that belong in module_mapping
, and imports I hadn't realized we had that'll need some finagling.
An example of the last one was a dependency on an in-house compiled C extension module. Or funny import tricks like:
try:
import foo
except ImportError:
import bar
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.
Just finished with the monorepo. Nothing too surprising. The only one that got me was an import like foo.bar.baz
being unowned. I added a BUILD
file to ./foo/bar
(no BUILD
files any higher) and declared a python_requirement
with module "baz"
(just to silence the warning, wouldn't pass the test) and still saw the error.
Instead I had to declare the module as "foo.bar.baz"
. Not sure if that change makes sense, or works around Pants' shortcomings in some way 🤔
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 added a
BUILD
file to./foo/bar
(noBUILD
files any higher) and declared apython_requirement
with module"baz"
(just to silence the warning, wouldn't pass the test) and still saw the error.
I think that this makes sense... python_requirement
targets do not have source roots applied, so foo.bar
would not have been prefixed onto baz
in this case.
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, looks good!
Unfortunately, it looks like `--no-print-stacktrace` broke in a critical location a while back, resulting in unnecessary noise. See for example: #13491 (comment) Fix, and add an integration test. Also fixes the location of the `exceptions.log`, and removes `ExceptionSink` `Ctrl+C` tests, since `Ctrl+C` is now directly handled by the engine (fixes #12108). [ci skip-rust] [ci skip-build-wheels]
Unfortunately, it looks like `--no-print-stacktrace` broke in a critical location a while back, resulting in unnecessary noise. See for example: pantsbuild#13491 (comment) Fix, and add an integration test. Also fixes the location of the `exceptions.log`, and removes `ExceptionSink` `Ctrl+C` tests, since `Ctrl+C` is now directly handled by the engine (fixes pantsbuild#12108). [ci skip-rust] [ci skip-build-wheels]
Unfortunately, it looks like `--no-print-stacktrace` broke in a critical location a while back, resulting in unnecessary noise. See for example: pantsbuild#13491 (comment) Fix, and add an integration test. Also fixes the location of the `exceptions.log`, and removes `ExceptionSink` `Ctrl+C` tests, since `Ctrl+C` is now directly handled by the engine (fixes pantsbuild#12108). [ci skip-rust] [ci skip-build-wheels]
Unfortunately, it looks like `--no-print-stacktrace` broke in a critical location a while back, resulting in unnecessary noise. See for example: #13491 (comment) Fix, and add an integration test. Also fixes the location of the `exceptions.log`, and removes `ExceptionSink` `Ctrl+C` tests, since `Ctrl+C` is now directly handled by the engine (fixes #12108). [ci skip-rust] [ci skip-build-wheels]
Unfortunately, it looks like `--no-print-stacktrace` broke in a critical location a while back, resulting in unnecessary noise. See for example: #13491 (comment) Fix, and add an integration test. Also fixes the location of the `exceptions.log`, and removes `ExceptionSink` `Ctrl+C` tests, since `Ctrl+C` is now directly handled by the engine (fixes #12108). [ci skip-rust] [ci skip-build-wheels]
We can probably land this whenever it's green in CI. If you need help with that, let me know! |
Oh I wouldn't want that until I've added tests 😁 💪 Also I think we still want the whitelist support. |
Dropped the "Draft" status after adding tests. 🚀 |
Actually, I want to add a few more tests, for some good coverage 👍 |
Officially good to go! |
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!
register( | ||
"--unowned-dependency-behavior", | ||
type=UnownedDependencyUsage, | ||
default=UnownedDependencyUsage.DoNothing, |
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 added a
BUILD
file to./foo/bar
(noBUILD
files any higher) and declared apython_requirement
with module"baz"
(just to silence the warning, wouldn't pass the test) and still saw the error.
I think that this makes sense... python_requirement
targets do not have source roots applied, so foo.bar
would not have been prefixed onto baz
in this case.
# Building wheels and fs_util will be skipped. Delete if not intended. [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]
Co-authored-by: Stu Hood <stuhood@gmail.com> # 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]
Co-authored-by: Stu Hood <stuhood@gmail.com> # 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]
# 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]
# 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]
Co-authored-by: Stu Hood <stuhood@gmail.com> # 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]
# 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]
# 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]
# 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]
# 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]
[ci skip-rust] [ci skip-build-wheels]
2753635
to
8aeb6f1
Compare
As discussed in Slack, adding a way to flag deps that are silently unowned.