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

Lint: Implement check for spaces, not tabs per PEP 12 #2379

Merged
merged 2 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ repos:
# Local checks for PEP headers and more
- repo: local
hooks:
- id: check-no-tabs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using the remove-tabs hook (https://pre-commit.com/hooks) in another project that will not just flag tabs but also replace them with four spaces.

Shall we use that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that hook is what I use in my other projects as well. I didn't use that here since unlike on those projects, AFAIK most authors/editors don't run the hooks locally and instead its mostly run on CI, where the replacement doesn't matter, and it maintains the status quo of all the hooks we use being either first party or local, rather than on code from individual third party repos.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a strong preference for warn+fix over only warn.

For those authors/editors don't run it locally, it's all the same.

But autofix is really useful for those of us who do run locally.

I don't see a need to restrict to only first party or local, and we already have third-party https://github.com/codespell-project/codespell.

And infact we could add https://pre-commit.ci to autofix PRs. I'm also using this for other repos and I find it very useful: no need for a reviewer to ask the author to make changes, then wait for them to make them, and check they made them properly.

We also have a number autofixers from https://github.com/pre-commit/pre-commit-hooks as well which could benefit from https://pre-commit.ci.

There's precedence in this org, https://github.com/python/typeshed already uses https://pre-commit.ci (added in python/typeshed#5552).

@JelleZijlstra: how's your experience been with https://pre-commit.ci/ on https://github.com/python/typeshed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been great on typeshed and saved a lot of time. It doesn't seem as important on this repo though because far fewer PRs run into CI issues that pre-commit could fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a strong preference for warn+fix over only warn. For those authors/editors don't run it locally, it's all the same. But autofix is really useful for those of us who do run locally.

I strongly do so as well, and rely heavily on this in many other repos I maintain, but this is a bit of a special case. Based on this repo's history, this check should trigger quite rarely (one table in one series of PEPs as of now), we currently only rely on first or second-party hooks for checks that aren't manual-only, and this repo has (AFAIK) much more limited use of the hooks locally than any of the others I work on.

I don't see a need to restrict to only first party or local, and we already have third-party https://github.com/codespell-project/codespell.

That's true, but it isn't installed and run via pre-commit install or on CI; it must be explicitly requested manually by the user (typically after reading our docs explaining how to do so).

And infact we could add https://pre-commit.ci/ to autofix PRs. I'm also using this for other repos and I find it very useful: no need for a reviewer to ask the author to make changes, then wait for them to make them, and check they made them properly.

Pre-commit CI has some pretty serious limitations, particularly as to what hooks it can run; see pre-commit/action#118 . Furthermore, it is very unlikely to ever trigger (see above and next item), and I'd rather not spend this repo's limited churn budget adding it, especially when it is pretty strained already.

We also have a number autofixers from https://github.com/pre-commit/pre-commit-hooks as well which could benefit from https://pre-commit.ci/.

We only have a grand total of three hooks that offer autofixing:

  • mixed-line-ending, which is autofixed locally by our .gitattributes config (its only there as a backstop for the local checkout)
  • fix-byte-order-marker, which again is there as a backstop and I don't think I've actually seen trigger on any repo I manage
  • file-contents-sorter, which only affects the Codespell ignore words list which realistically is only going to be updated by you or me, who both presumably have pre-commit locally.

As @JelleZijlstra also alluded to, these autofixers should never actually trigger on CI (as opposed to locally), and I don't think I've seen a single PR on this repo on which they have (and even the other checks trigger pretty rarely). As mentioned above, the tab check is unlikely to trigger more than very rarely, and is a few seconds total to fix in any editor. So in total, it is likely that even 10 years from now it would never pay back even the time we've spent haggling about it 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this is still a good improvement, thanks!

name: "Check tabs not used in PEPs"
language: pygrep
entry: '\t'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: check-required-fields
name: "Check PEPs have all required fields"
language: pygrep
Expand Down
192 changes: 96 additions & 96 deletions pep-8100.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,102 +200,102 @@ Active Python core developers

::

Alex Gaynor
Alex Martelli
Alexander Belopolsky
Alexandre Vassalotti
Amaury Forgeot d'Arc
Andrew Kuchling
Andrew Svetlov
Antoine Pitrou
Armin Ronacher
Barry Warsaw
Benjamin Peterson
Berker Peksag
Brett Cannon
Brian Curtin
Carol Willing
Chris Jerdonek
Chris Withers
Christian Heimes
David Malcolm
David Wolever
Davin Potts
Dino Viehland
Donald Stufft
Doug Hellmann
Eli Bendersky
Emily Morehouse
Éric Araujo
Eric Snow
Eric V. Smith
Ethan Furman
Ezio Melotti
Facundo Batista
Fred Drake
Georg Brandl
Giampaolo Rodola'
Gregory P. Smith
Guido van Rossum
Hyeshik Chang
Hynek Schlawack
INADA Naoki
Ivan Levkivskyi
Jack Diederich
Jack Jansen
Jason R. Coombs
Jeff Hardy
Jeremy Hylton
Jesús Cea
Julien Palard
Kurt B. Kaiser
Kushal Das
Larry Hastings
Lars Gustäbel
Lisa Roach
Łukasz Langa
Marc-Andre Lemburg
Mariatta
Mark Dickinson
Mark Hammond
Mark Shannon
Martin Panter
Matthias Klose
Meador Inge
Michael Hudson-Doyle
Nathaniel J. Smith
Ned Deily
Neil Schemenauer
Nick Coghlan
Pablo Galindo
Paul Moore
Petr Viktorin
Petri Lehtinen
Philip Jenvey
R. David Murray
Raymond Hettinger
Robert Collins
Ronald Oussoren
Sandro Tosi
Senthil Kumaran
Serhiy Storchaka
Sjoerd Mullender
Stefan Krah
Steve Dower
Steven Daprano
T. Wouters
Tal Einat
Terry Jan Reedy
Thomas Heller
Tim Golden
Tim Peters
Trent Nelson
Victor Stinner
Vinay Sajip
Walter Dörwald
Xiang Zhang
Yury Selivanov
Zachary Ware
Alex Gaynor
Alex Martelli
Alexander Belopolsky
Alexandre Vassalotti
Amaury Forgeot d'Arc
Andrew Kuchling
Andrew Svetlov
Antoine Pitrou
Armin Ronacher
Barry Warsaw
Benjamin Peterson
Berker Peksag
Brett Cannon
Brian Curtin
Carol Willing
Chris Jerdonek
Chris Withers
Christian Heimes
David Malcolm
David Wolever
Davin Potts
Dino Viehland
Donald Stufft
Doug Hellmann
Eli Bendersky
Emily Morehouse
Éric Araujo
Eric Snow
Eric V. Smith
Ethan Furman
Ezio Melotti
Facundo Batista
Fred Drake
Georg Brandl
Giampaolo Rodola'
Gregory P. Smith
Guido van Rossum
Hyeshik Chang
Hynek Schlawack
INADA Naoki
Ivan Levkivskyi
Jack Diederich
Jack Jansen
Jason R. Coombs
Jeff Hardy
Jeremy Hylton
Jesús Cea
Julien Palard
Kurt B. Kaiser
Kushal Das
Larry Hastings
Lars Gustäbel
Lisa Roach
Łukasz Langa
Marc-Andre Lemburg
Mariatta
Mark Dickinson
Mark Hammond
Mark Shannon
Martin Panter
Matthias Klose
Meador Inge
Michael Hudson-Doyle
Nathaniel J. Smith
Ned Deily
Neil Schemenauer
Nick Coghlan
Pablo Galindo
Paul Moore
Petr Viktorin
Petri Lehtinen
Philip Jenvey
R. David Murray
Raymond Hettinger
Robert Collins
Ronald Oussoren
Sandro Tosi
Senthil Kumaran
Serhiy Storchaka
Sjoerd Mullender
Stefan Krah
Steve Dower
Steven Daprano
T. Wouters
Tal Einat
Terry Jan Reedy
Thomas Heller
Tim Golden
Tim Peters
Trent Nelson
Victor Stinner
Vinay Sajip
Walter Dörwald
Xiang Zhang
Yury Selivanov
Zachary Ware


.. [1] This repository is private and accessible only to Python Core
Expand Down
164 changes: 82 additions & 82 deletions pep-8101.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,88 +186,88 @@ Active Python core developers

::

Abhilash Raj
Alex Gaynor
Alex Martelli
Alexander Belopolsky
Andrew Kuchling
Andrew Svetlov
Antoine Pitrou
Barry Warsaw
Benjamin Peterson
Berker Peksağ
Brett Cannon
Brian Curtin
Brian Quinlan
Carol Willing
Cheryl Sabella
Chris Withers
Christian Heimes
Christian Tismer
Davin Potts
Dino Viehland
Donald Stufft
Emily Morehouse
Éric Araujo
Eric Snow
Eric V. Smith
Ethan Furman
Ezio Melotti
Facundo Batista
Fred Drake
Giampaolo Rodolà
Gregory P. Smith
Guido van Rossum
Inada Naoki
Ivan Levkivskyi
Jason R. Coombs
Jeremy Kloth
Jesús Cea
Joannah Nanjekye
Julien Palard
Kurt B. Kaiser
Kushal Das
Larry Hastings
Lisa Roach
Łukasz Langa
Marc-André Lemburg
Mariatta
Mark Dickinson
Mark Shannon
Matthias Klose
Michael Foord
Nathaniel J. Smith
Ned Deily
Neil Schemenauer
Nick Coghlan
Pablo Galindo
Paul Ganssle
Paul Moore
Petr Viktorin
R. David Murray
Raymond Hettinger
Robert Collins
Ronald Oussoren
Senthil Kumaran
Serhiy Storchaka
Skip Montanaro
Stefan Behnel
Stefan Krah
Steve Dower
Steven D'Aprano
Stéphane Wirtel
Tal Einat
Terry Jan Reedy
Thomas Wouters
Tim Golden
Tim Peters
Victor Stinner
Vinay Sajip
Walter Dörwald
Xavier de Gaye
Xiang Zhang
Yury Selivanov
Zachary Ware
Abhilash Raj
Alex Gaynor
Alex Martelli
Alexander Belopolsky
Andrew Kuchling
Andrew Svetlov
Antoine Pitrou
Barry Warsaw
Benjamin Peterson
Berker Peksağ
Brett Cannon
Brian Curtin
Brian Quinlan
Carol Willing
Cheryl Sabella
Chris Withers
Christian Heimes
Christian Tismer
Davin Potts
Dino Viehland
Donald Stufft
Emily Morehouse
Éric Araujo
Eric Snow
Eric V. Smith
Ethan Furman
Ezio Melotti
Facundo Batista
Fred Drake
Giampaolo Rodolà
Gregory P. Smith
Guido van Rossum
Inada Naoki
Ivan Levkivskyi
Jason R. Coombs
Jeremy Kloth
Jesús Cea
Joannah Nanjekye
Julien Palard
Kurt B. Kaiser
Kushal Das
Larry Hastings
Lisa Roach
Łukasz Langa
Marc-André Lemburg
Mariatta
Mark Dickinson
Mark Shannon
Matthias Klose
Michael Foord
Nathaniel J. Smith
Ned Deily
Neil Schemenauer
Nick Coghlan
Pablo Galindo
Paul Ganssle
Paul Moore
Petr Viktorin
R. David Murray
Raymond Hettinger
Robert Collins
Ronald Oussoren
Senthil Kumaran
Serhiy Storchaka
Skip Montanaro
Stefan Behnel
Stefan Krah
Steve Dower
Steven D'Aprano
Stéphane Wirtel
Tal Einat
Terry Jan Reedy
Thomas Wouters
Tim Golden
Tim Peters
Victor Stinner
Vinay Sajip
Walter Dörwald
Xavier de Gaye
Xiang Zhang
Yury Selivanov
Zachary Ware


.. [1] This repository is private and accessible only to Python Core
Expand Down
Loading