openzim / _python-bootstrap

Sample openZIM Python project bootstrap
1 stars 2 forks source link

Move `.pre-commit.yaml` to hatch #51

Open benoit74 opened 2 weeks ago

benoit74 commented 2 weeks ago

See https://github.com/openzim/devdocs/pull/37#discussion_r1832039501

rgaudin commented 2 weeks ago

If that's possible, that would be great indeed!

josephlewis42 commented 2 weeks ago

I think I've boiled this down to the following for openzim/devdocs, however I'm not a pre-commit or Python tooling expert so there might be missing bits:

# 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
  -   id: end-of-file-fixer
- repo: local
  hooks:
  -   id: "lint"
      name: "hatch run lint:all"
      entry: hatch
      language: system
      args: ["run", "lint:all"]
      require_serial: true
      pass_filenames: false
  -   id: "pyright"
      name: "pyright (hatch)"
      description: 'pyright static type checker'
      entry: hatch
      language: system
      'types_or': [python, pyi]
      args: ["run", "check:pyright"]
      require_serial: true
      pass_filenames: false
benoit74 commented 1 week ago

Thank you. Doesn't this means that tools are ran on all files instead of only modified ones? This would be a bit sad. Using repo: local is anyway an interesting path to follow.