Skip to content
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

bpo-44854: Add .editorconfig file to help enforce make patchcheck #27638

Merged
merged 2 commits into from Aug 10, 2021
Merged
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -0,0 +1,12 @@
root = true

[*.{py,c,cpp,h,rst,md,yml}]
trim_trailing_whitespace = true
This conversation was marked as resolved by ambv

This comment has been minimized.

@serhiy-storchaka

serhiy-storchaka Aug 9, 2021
Member

Note that there are currently many imported or generated files with trailing spaces: files for building on Windows and macOS (*.wixproj, *.wxs, *.icns, *.nib, etc), test data files (for xml, email, etc), sources of third-party libraries (libffi, blake2), etc.
Try to run

git ls-tree -r main --name-only | tr '\n' '\0' | xargs -0 sed -ri -e 's/ +$//'

and then

git diff --stat

to get a list of files containing trailing spaces.

This comment has been minimized.

@ambv

ambv Aug 9, 2021
Author Contributor

In this case I can move this directive to only address .py, .c, .h, .rst, .md, .yml. What do you think?

This comment has been minimized.

@ambv

ambv Aug 9, 2021
Author Contributor

By the way, shouldn't make patchcheck complain about this trailing whitespace?

This comment has been minimized.

@ambv

ambv Aug 9, 2021
Author Contributor

Running the suggested sed and then aggregating data by file extension it looks like this:

  40 wxs
  20 wixproj
  14 c
  11 h
   9 icns
   7 xml
   6 pem
   6 ico
   4 txt
   4 rtf
   4 png
   4 TXT
   3 rc
   3 py
   3 html
   3 S
   2 wav
   2 targets
   2 au
   2 aiff
   2 2
   1 xbm
   1 wxl
   1 thm
   1 sample
   1 pyobjc
   1 psd
   1 ps
   1 pdf
   1 patch
   1 md
   1 lproj/PreferenceWindow
   1 lproj/MyDocument
   1 lproj/MainMenu
   1 github/problem-matchers/sphinx
   1 github/SECURITY
   1 def
   1 cpp
   1 app/Contents/Resources/IDLE
   1 Modules/_ctypes/libffi_osx/README
   1 Modules/_ctypes/darwin/README
   1 Modules/_ctypes/darwin/LICENSE
   1 Lib/distutils/command/command_template
   1 4
   1 3

So yeah, I do think that limiting whitespace trimming to the extensions I highlighted above will do the job.

This comment has been minimized.

@serhiy-storchaka

serhiy-storchaka Aug 9, 2021
Member

LGTM. And maybe exclude some directories like Modules/_blake2/impl/, Modules/_ctypes/libffi_osx/, etc? I am not sure what is the status of these files and how they are supposed to be synchronized with upstream.

As for patcheck, it is just not used for C files.

insert_final_newline = true
indent_style = space

[*.{py,c,cpp,h}]
indent_size = 4

[*.yml]
indent_size = 2