This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add .editorconfig to the root directory
Type: enhancement Stage: resolved
Components: Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, miss-islington, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2021-08-06 18:37 by lukasz.langa, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27638 merged lukasz.langa, 2021-08-06 18:39
PR 27689 merged serhiy.storchaka, 2021-08-09 17:17
PR 27714 merged miss-islington, 2021-08-10 16:43
PR 27712 merged miss-islington, 2021-08-10 16:43
PR 27713 merged miss-islington, 2021-08-10 16:44
Messages (9)
msg399123 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-06 18:37
EditorConfig is a cross-editor configuration file that is pretty widely adopted: https://editorconfig.org/

Adding this to the root directory will allow editors that use the file to automatically format a few details which we already enforce with `make patchcheck`:

- always put an empty line at the end of the file;
- remove trailing whitespace;
- disallow tabs in Python (PEP 8) and C (PEP 7) files.
msg399202 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-08-07 19:15
I presume 'root directory' mean the repository directory.

I would have to think about supporting this in IDLE.  It already, I believe (or will), enforces the two whitespace rules when saving and defaults to 4-space indents for first lines of statements.  Enforcing that for repository .py and .c files would be good, but there is currently no mechanism for per-file settings.

I did not see anything in the EditorConfig guide about what happens when .editorconfig does not start with root = true and another file is found.
msg399269 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-09 14:25
> I did not see anything in the EditorConfig guide about what happens when .editorconfig does not start with root = true and another file is found.

Good question. The docs do mention this but the information is scattered across the website. The key points are:

> EditorConfig files are read top to bottom and the most recent rules found take precedence. Properties from matching EditorConfig sections are applied in the order they were read, so properties in closer files take precedence.

> When opening a file, EditorConfig plugins look for a file named .editorconfig in the directory of the opened file and in every parent directory. A search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found.

In other words, unless root=True is specified, the editor will keep looking for .editorconfig also in parent directories as well and composing the config from all files it found.
msg399284 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-09 18:33
New changeset 058fb35b57ca8c5063d16ec818e668b3babfea65 by Serhiy Storchaka in branch 'main':
bpo-44854: Remove trailing whitespaces (GH-27689)
https://github.com/python/cpython/commit/058fb35b57ca8c5063d16ec818e668b3babfea65
msg399340 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-10 16:31
New changeset c0ab59f7de1906feee21c057ad433fad924d1e38 by Łukasz Langa in branch 'main':
bpo-44854: Add .editorconfig file to help enforce `make patchcheck` (GH-27638)
https://github.com/python/cpython/commit/c0ab59f7de1906feee21c057ad433fad924d1e38
msg399343 - (view) Author: miss-islington (miss-islington) Date: 2021-08-10 17:06
New changeset a6808c6378ccfd732285ee20319658ac29eacf4c by Miss Islington (bot) in branch '3.10':
bpo-44854: Add .editorconfig file to help enforce `make patchcheck` (GH-27638)
https://github.com/python/cpython/commit/a6808c6378ccfd732285ee20319658ac29eacf4c
msg399345 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-10 17:09
New changeset 7f88aeadc19b1d3ece4723efb240e6d6753570b9 by Miss Islington (bot) in branch '3.8':
bpo-44854: Add .editorconfig file to help enforce `make patchcheck` (GH-27638) (GH-27713)
https://github.com/python/cpython/commit/7f88aeadc19b1d3ece4723efb240e6d6753570b9
msg399346 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-10 17:22
New changeset d27e2f4d118e7a9909b6a3e5da06c5ff95806a85 by Miss Islington (bot) in branch '3.9':
bpo-44854: Add .editorconfig file to help enforce `make patchcheck` (GH-27638) (GH-27714)
https://github.com/python/cpython/commit/d27e2f4d118e7a9909b6a3e5da06c5ff95806a85
msg399347 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-10 17:24
Thanks everybody for review! ✨ 🍰 ✨
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89017
2021-08-10 17:24:08lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg399347

stage: patch review -> resolved
2021-08-10 17:22:23lukasz.langasetmessages: + msg399346
2021-08-10 17:09:03lukasz.langasetmessages: + msg399345
2021-08-10 17:06:26miss-islingtonsetmessages: + msg399343
2021-08-10 16:44:37miss-islingtonsetpull_requests: + pull_request26198
2021-08-10 16:43:35miss-islingtonsetpull_requests: + pull_request26197
2021-08-10 16:43:22miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26196
2021-08-10 16:31:08lukasz.langasetmessages: + msg399340
2021-08-09 18:33:02serhiy.storchakasetmessages: + msg399284
2021-08-09 17:17:50serhiy.storchakasetnosy: + serhiy.storchaka
pull_requests: + pull_request26175
2021-08-09 14:25:19lukasz.langasetmessages: + msg399269
2021-08-07 19:15:33terry.reedysetnosy: + terry.reedy
messages: + msg399202
2021-08-06 18:39:42lukasz.langasetkeywords: + patch
stage: patch review
pull_requests: + pull_request26132
2021-08-06 18:37:22lukasz.langacreate