-
-
Notifications
You must be signed in to change notification settings - Fork 643
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 flake8 plugin to check textwrap.dedent
usage.
#17467
Conversation
textwrap.dedent
usage.
Before: 12:27:46.73 [WARN] DEPRECATED: exporting resolves without using the --resolve option is scheduled to be removed in version 2.23.0.dev0. Use the --resolve flag one or more times to name the resolves you want to export, and don't provide any target specs. E.g., `./pants export --resolve=python-default --resolve=pytest` After: 12:31:47.95 [WARN] DEPRECATED: exporting resolves without using the --resolve option is scheduled to be removed in version 2.23.0.dev0. Use the --resolve flag one or more times to name the resolves you want to export, and don't provide any target specs. E.g., ./pants export --resolve=python-default --resolve=pytest
Why? What is bad about using dedent? |
Are we certain that softwrap emits the same as dedent in cases where that is what we'd want? |
Dedent works well for code blocks, but doesn't reflow lines to adapt to the terminal width for text like messages etc.
@thejcannon has written pretty extensive tests to ensure the formatting works in a predictable manner. The one case where it doesn't, is when you want hard line breaks. Example: pants/src/python/pants/engine/target.py Lines 2890 to 2924 in e9ae0a3
Tests for pants/src/python/pants/util/strutil_test.py Lines 172 to 361 in e9ae0a3
|
Ah yes, that is why I didn't use softwrap, because I couldn't get the hard linebreaks to work. But that renders fine, I'm not fussy about the backticks, so it's fine. |
#17465 (comment) spurred me to add this flake8 lint rule. Not that it was an oversight in this case, but for anyone else not familiar with
softwrap
, this will help them find it rather thandedent
.It does not check test sources, so using
dedent
in tests are still perfectly valid.