-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Check for whitespace in CI #429
Comments
I remembered I got a PoC branch lying around: https://github.com/erlend-aasland/cpython/tree/add-whitespace-linter |
Sounds good. Looking at the erlend-aasland/cpython#14 PoC, some ideas:
|
+1
Oooh, that sure looks nice! |
Here's an example: hugovk/cpython#22 There's currently a lot of files with trimmable trailing whitespace, see:
So we could limit it to certain file types. For example |
Neat! Much more elegant than my PoC 😅
+1 |
I've updated hugovk/cpython#22 to remove the trailing whitespace, and add: types_or: [c, python]
exclude: ^Lib/test/test_argparse.py$ I excluded that file because a couple of its asserts depend on trailing whitespace: https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Lib/test/test_argparse.py#L2179 |
These whitespaces are invisible to a programmer who reads the assertions. Can the following be used instead? self.assertEqual(parser.format_help(), textwrap.dedent('''\
usage: PROG [-h] {}
main description
positional arguments:
- {}
+ {} ''' + '''
options:
-h, --help show this help message and exit
''')) |
I agree that's better. Also a comment explaining why there are trailing spaces and why the string is constructed that way would help. |
Well turns out there was already a whitespace check run on the CI as part of It was broken but has now been fixed: python/cpython#31708 Do we still need the pre-commit suggestion in hugovk/cpython#22 or this issue? |
I think it would be nice to have the patchcheck as its own GitHub Action with its own green checkmark, so that sort of common issue gets noticed within seconds, rather than having to wait on the build and the whole test suite to run. Theoretically, I think we should be able to use |
Please see PR python/cpython#104275. |
Consider adding a CI check for whitespace errors, a la
git diff --check
.I've seen this idea surface a couple of times, most recently by @JelleZijlstra in python/cpython#31695 (comment)
The text was updated successfully, but these errors were encountered: