Skip to content

Port lint scripts to Python #24783

@laanwj

Description

@laanwj

To prevent endless issues when running the linters locally (say, on specific versions of bash, or system tools having certain names, or a certain implementation of sed, etc) , as well as for maintainability/reviewability, it's preferred for linter scripts to be written in Python.

Here is a list of scripts, feel free to pick up any that haven't been ported:

Although I try to keep this post up to date, before starting on a linter, please first do a github search in PRs to see if a PR for that already exists.

Guidelines

  • Don't forget to update test/README.md when the name of a script changes.
  • Avoid shell=true on subprocess calls. Remember that the point here is to avoid shell ambiguities.
  • If possible, avoid calling out to subprocesses at all and use what Python APIs provide (say, grep sed awk sha256sum). An exception if this would introduce further dependencies that need to be installed. These are OK to use subprocess for:
    • git subcommands including git grep—the alternative would be to require an extra dependency on a Python git module, also, git can be assumed to be the same implementation everywhere
    • Other scripts in the source tree.
    • External linters (vulture, codespell, etc) that provide only a command-based interface.
  • Some further recommendations about Python usage here: lint: convert spellchecking lint test to python #24766 (review)

Useful skills:

  • Python
  • Being able to read shell script

Want to work on this issue?

For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions