Skip to content

make patchcheck: Allow Tabs in Some Cases #92266

Description

@ericsnowcurrently

Currently Tools/patchcheck/reindent.py1 replaces all tabs with spaces. However, in Tools/c-analyzer/cpython._parser.py there are embedded tab-based tables. Up to now I've basically ignored CI failures (from make patchcheck) in _parser.py, but I'd rather reindent.py be a little smarter (even if just a whitelist). 2 Tools/scripts/untabify.py sounds like it may have a similar story.

Linked PRs

Footnotes

  1. reindent.check() is used by Tools/patchcheck/patchcheck.py (AKA make patchcheck). ↩

  2. Addressing trailing-tabs-in-str-literals is even more relevant since I enabled the check-c-globals CI check. For example, see https://github.com/python/cpython/pull/102735#issuecomment-1470516458. ↩

Activity

  1. changed the title [-]make patchcheck: Allow tabs in some cases.[/-] [+]make patchcheck: Allow Tabs in Some Cases[/+] on May 3, 2022
  2. serhiy-storchaka commented on May 4, 2022

    @serhiy-storchaka
    Member

    Why not to use \t instead of literal tab?

  3. ezio-melotti commented on May 4, 2022

    @ezio-melotti
    Member

    I think this is the mentioned table:

    MACROS = clean_lines('''
    # @begin=tsv@
    glob name value
    Include/internal/*.h Py_BUILD_CORE 1
    Python/**/*.c Py_BUILD_CORE 1
    Parser/**/*.c Py_BUILD_CORE 1
    Objects/**/*.c Py_BUILD_CORE 1
    Modules/_asynciomodule.c Py_BUILD_CORE 1

    Here \ts would make it less readable. Would it make sense to move that to a stand-alone .tsv file?

  4. ericsnowcurrently commented on May 5, 2022

    @ericsnowcurrently
    MemberAuthor

    Here \ts would make it less readable.

    Correct.

    Would it make sense to move that to a stand-alone .tsv file?

    I considered that but didn't have time to try it out. I'd rather have that particular data stay in the current file if possible though. One alternative is to switch to csv. I don't recall that these specific tables need tsv.

  5. ericsnowcurrently commented on Mar 16, 2023

    @ericsnowcurrently
    MemberAuthor
  6. hugovk commented on Jun 26, 2025

    @hugovk
    Member

    Up to now I've basically ignored CI failures (from make patchcheck) in _parser.py

    Tools/patchcheck/reindent.py is no longer run as part of make patchcheck, and patchcheck is no longer run on the CI.

    reindent.py includes a few lints:

    • strip trailing whitespace (now done by trailing-whitespace in CI via pre-commit)
    • replace tabs with spaces
    • reindent to multiples of four-space indents

    PR #135983 re-adds the second of these to the CI via pre-commit.

    but I'd rather reindent.py be a little smarter (even if just a whitelist).

    PR #135984 adds Tools/c-analyzer/cpython/_parser.py to an allowlist in reindent.py so its tabs are not changed. But as reindent.py is no longer part of the CI, and therefore less often run, this is less pressing.

    Tools/scripts/untabify.py sounds like it may have a similar story.

    It does. We could easily add an allowlist here too, possibly shared with reindent.py. However, this is not run by the CI, by any make commands, nor is recommended by the devguide, so I've not changed it.

  7. added a commit that references this issue on Jun 27, 2025
  8. added 2 commits that reference this issue on Jun 27, 2025
  9. added 2 commits that reference this issue on Jun 27, 2025
  10. added a commit that references this issue on Jul 11, 2025
  11. added a commit that references this issue on Jul 12, 2025
  12. added a commit that references this issue on Aug 4, 2025
  13. added a commit that references this issue on Aug 19, 2025
  14. added a commit that references this issue on Sep 17, 2025
  15. AA-Turner commented on Sep 17, 2025

    @AA-Turner
    Member

    The tabs have been removed from Tools/c-analyzer/cpython/_parser.py & there are no other instances, as far as I'm aware. Going forwards, I think we should just avoid embedded tabs.

    A

  16. added a commit that references this issue on Oct 1, 2025
  17. added 2 commits that reference this issue on Oct 1, 2025
  18. added a commit that references this issue on Oct 7, 2025
  19. added 2 commits that reference this issue on Oct 8, 2025
  20. added a commit that references this issue on Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions