vss-tools icon indicating copy to clipboard operation
vss-tools copied to clipboard

update pre-commit hooks

Open nwesem opened this issue 10 months ago • 3 comments

Hi everyone, I realized that we are not using the full functionality of pre-commit, so I'm suggesting that we update it to use all standard hooks for python-based projects. I extended the current one with pyupgrade, isort, black, ruff, markdownlint-cli2, and codespell. Please see suggested change below.

Regarding pyupgrade we could use python 3.8+ for now eventhough I would recommend to go for at least 3.10+

As this changes many files of the project I created this issue for discussion.

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
    -   id: trailing-whitespace
        exclude_types: ["csv", "proto"]
    -   id: end-of-file-fixer
        exclude_types: ["json", "proto"]
        exclude: ".*\\.[fidl|jsonschema]"
    -   id: check-yaml
    -   id: check-added-large-files
  - repo: https://github.com/pycqa/flake8
    rev: '7.0.0'
    hooks:
    -   id: flake8
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.3.1
    hooks:
      - id: pyupgrade
        args: [ --py38-plus ]
  - repo: https://github.com/pycqa/isort
    rev: 5.12.0
    hooks:
      - id: isort
        args: ["--profile", "black", "--filter-files"]
  - repo: https://github.com/psf/black
    rev: 23.10.1
    hooks:
      - id: black
  - repo: https://github.com/astral-sh/ruff-pre-commit
    # Ruff version.
    rev: v0.1.1
    hooks:
      - id: ruff
  - repo: https://github.com/DavidAnson/markdownlint-cli2
    rev: v0.12.1
    hooks:
      - id: markdownlint-cli2
        args:
          - --fix
  - repo: https://github.com/codespell-project/codespell
    rev: v2.2.4
    hooks:
      - id: codespell

nwesem avatar Apr 02 '24 09:04 nwesem

MoM:

  • Please discuss
  • PP: Python 3.8 is soon out of life, good to get rid of
  • Erik: What is oldest Python version you have interest in? Anyone using for instance 3.9?
  • PP: In installation instructions show how to install/run using venv, then we could specify version
  • Adnan: Possibly use 3.11+
  • PP: Some may use own python code on top that require 3.8
  • PP: 3.10 is default for Ubuntu22.04

erikbosch avatar Apr 02 '24 14:04 erikbosch

Some thought from my side - In general I am positive but we need to make sure that Continuous integration continue to work. Maybe update to some 3.10 version in files like https://github.com/COVESA/vss-tools/blob/master/Pipfile and https://github.com/COVESA/vss-tools/blob/master/.github/workflows/buildcheck.yml

erikbosch avatar Apr 02 '24 15:04 erikbosch

MoM:

  • Niclas: Will give it a try, but many files changes
  • Erik: We only run it for changed files as of today.
  • Possibly first check a small subset so we can check if changes are accepted

erikbosch avatar Apr 30 '24 14:04 erikbosch