-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Warn when dependency inference does not infer something in your resolve #15326
Comments
I don't know if they're necessarily competing: it's possible that we should both 1) enable |
The dogfooding is good, especially as we consider changing the default for Pants to be warn or error (#15326).
If all deps belong to other resolveUnownedDependencyError: Pants cannot infer owners for the following imports in the file src/python/pants/util/strutil_test.py (from the target src/python/pants/util/strutil_test.py:tests):
These imports are already known by Pants, only are not defined in the same "resolve" of
Pants can only infer imports on targets that share the same resolve. You may need to set the Otherwise, try the below ideas. -- If you do not expect an import to be inferrable, add Is the import from a third-party dependency (see https://www.pantsbuild.org/v2.12/docs/python-third-party-dependencies)? Some common issues:
Is the import from first-party code? Some common issues:
Some common issues with both first and third-party imports:
If some deps belong to other resolveOnly change is second paragraph UnownedDependencyError: Pants cannot infer owners for the following imports in the file src/python/pants/util/strutil_test.py (from the target src/python/pants/util/strutil_test.py:tests):
Some of these imports are already known by Pants, only are not defined in the same "resolve" of
Pants can only infer imports on targets that share the same resolve. You may need to set the Otherwise, try the below ideas. -- If you do not expect an import to be inferrable, add Is the import from a third-party dependency (see https://www.pantsbuild.org/v2.12/docs/python-third-party-dependencies)? Some common issues:
Is the import from first-party code? Some common issues:
Some common issues with both first and third-party imports:
|
IMO, we should absolutely lean on this being documented on the docsite, and stop after the high level explanation.
...and then most of the explanation to the "multiple resolves" section on https://www.pantsbuild.org/docs/python-third-party-dependencies#multiple-lockfiles |
…cy_behavior` (#15334) This mostly points at https://www.pantsbuild.org/v2.11/docs/troubleshooting#import-errors-and-missing-dependencies because we decided it was too noisy of a warning/error message to reproduce the whole guide. We want the terminal to highlight diagnostics unique to the particular issue, and leave general guidance elsewhere. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` Closes #15326 by improving the error message when resolves are likely the culprit. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) These imports are not in the resolve used by the target (`another`), but they were present in other resolves: * pants.util.strutil.bullet_list: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_binary: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_text: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.first_paragraph: 'python-default' from src/python/pants/util/strutil.py ... * pytest: 'python-default' from 3rdparty/python#pytest If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` [ci skip-rust]
…cy_behavior` (Cherry-pick of pantsbuild#15334) This mostly points at https://www.pantsbuild.org/v2.11/docs/troubleshooting#import-errors-and-missing-dependencies because we decided it was too noisy of a warning/error message to reproduce the whole guide. We want the terminal to highlight diagnostics unique to the particular issue, and leave general guidance elsewhere. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` Closes pantsbuild#15326 by improving the error message when resolves are likely the culprit. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) These imports are not in the resolve used by the target (`another`), but they were present in other resolves: * pants.util.strutil.bullet_list: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_binary: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_text: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.first_paragraph: 'python-default' from src/python/pants/util/strutil.py ... * pytest: 'python-default' from 3rdparty/python#pytest If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` [ci skip-rust] # Conflicts: # src/python/pants/backend/python/dependency_inference/rules.py # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…cy_behavior` (Cherry-pick of #15334) (#15389) * Improve `help` and error message for `[python-infer].unowned_dependency_behavior` (Cherry-pick of #15334) This mostly points at https://www.pantsbuild.org/v2.11/docs/troubleshooting#import-errors-and-missing-dependencies because we decided it was too noisy of a warning/error message to reproduce the whole guide. We want the terminal to highlight diagnostics unique to the particular issue, and leave general guidance elsewhere. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` Closes #15326 by improving the error message when resolves are likely the culprit. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) These imports are not in the resolve used by the target (`another`), but they were present in other resolves: * pants.util.strutil.bullet_list: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_binary: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_text: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.first_paragraph: 'python-default' from src/python/pants/util/strutil.py ... * pytest: 'python-default' from 3rdparty/python#pytest If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` [ci skip-rust]
…cy_behavior` (pantsbuild#15334) This mostly points at https://www.pantsbuild.org/v2.11/docs/troubleshooting#import-errors-and-missing-dependencies because we decided it was too noisy of a warning/error message to reproduce the whole guide. We want the terminal to highlight diagnostics unique to the particular issue, and leave general guidance elsewhere. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` Closes pantsbuild#15326 by improving the error message when resolves are likely the culprit. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) These imports are not in the resolve used by the target (`another`), but they were present in other resolves: * pants.util.strutil.bullet_list: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_binary: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_text: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.first_paragraph: 'python-default' from src/python/pants/util/strutil.py ... * pytest: 'python-default' from 3rdparty/python#pytest If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…cy_behavior` (Cherry-pick of #15334) (#15391) This mostly points at https://www.pantsbuild.org/v2.11/docs/troubleshooting#import-errors-and-missing-dependencies because we decided it was too noisy of a warning/error message to reproduce the whole guide. We want the terminal to highlight diagnostics unique to the particular issue, and leave general guidance elsewhere. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` Closes #15326 by improving the error message when resolves are likely the culprit. ``` UnownedDependencyError: Pants cannot infer owners for the following imports from the target src/python/pants/util/strutil_test.py:tests: * pants.util.strutil.bullet_list (line: 9) * pants.util.strutil.ensure_binary (line: 10) ... * pants.util.strutil.strip_prefix (line: 18) * pants.util.strutil.strip_v2_chroot_path (line: 19) * pytest (line: 6) These imports are not in the resolve used by the target (`another`), but they were present in other resolves: * pants.util.strutil.bullet_list: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_binary: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.ensure_text: 'python-default' from src/python/pants/util/strutil.py * pants.util.strutil.first_paragraph: 'python-default' from src/python/pants/util/strutil.py ... * pytest: 'python-default' from 3rdparty/python#pytest If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/v2.12/docs/troubleshooting#import-errors-and-missing-dependencies for common problems. ``` [ci skip-rust]
So, I just tried out adding another @Eric-Arellano , @thejcannon: It seemed like there was consensus around doing that: I can post a change next week, so that at least folks onboarding to EDIT: #16281 |
…ult. (#16281) Rough consensus was reached on #15326 and #14975 that enabling `unowned_dependency_behavior="warning"` by default would: 1. be helpful for new users, to guide them through fixing their missing dependencies 2. be useful in the case of adding additional resolves (due to the work done in #15326 to enrich the warning for that case) 3. reduce the chances of CI errors in #14975 (when users go a step further to make the warning an error) `2.14.x` is a relatively quiet release so far, so it seems like there is room in the budget for a new warning like this. The rendered message for this warning is very self-explanatory due to @thejcannon's original work, and @Eric-Arellano's followup work in #15326, so I don't see any obvious documentation changes that need to be made. [ci skip-build-wheels] [ci skip-rust]
Relates to #14864, but that is specifically for the
dependencies
field and does not tackle dependency inference.Two competing approaches:
[python-infer].unownded_dependency_behavior
default towarn
orerror
. Then enrich the error message to have "Did you mean?" likeNoCompatibleResolveException
should suggest remedies #14864 (comment)The text was updated successfully, but these errors were encountered: