ARBML/masader

Add `pre-commit`

ma7dev opened this issue · 12 comments

Tools to include

  • black - code formatter
  • mypy - static type checker
  • pycln - remove unused imports
  • isort - sort imports

Skeleton to start from

# 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.0.1
    hooks:
      - id: check-ast
      - id: check-builtin-literals
      - id: check-case-conflict
      - id: check-docstring-first
      - id: check-merge-conflict
      - id: check-json
      - id: check-toml
      - id: check-yaml
      - id: end-of-file-fixer
      - id: mixed-line-ending
      - id: trailing-whitespace
      - id: check-vcs-permalinks
      - id: check-shebang-scripts-are-executable
  - repo: https://github.com/pre-commit/pygrep-hooks
    rev: v1.9.0
    hooks:
      - id: python-check-mock-methods
      - id: python-no-log-warn
      - id: python-use-type-annotations
  - repo: https://github.com/hadialqattan/pycln
    rev: v1.2.5
    hooks:
      - id: pycln
        args: [--all]
  - repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
      - id: black
        additional_dependencies: ['click==8.0.4']
  - repo: https://github.com/PyCQA/isort
    rev: 5.10.1
    hooks:
      - id: isort
        args: ["--profile", "black"]

Thank u, I was thinking about this.

It seems that jekyll-pre-commit doesn't allow you to run pre-commit locally. We do have pre-commit configuration done correctly, but we don't want to install pre-commit through python. We would like to have some jekyll version of pre-commit to be able to utilize it when running bundle install (installing dependencies).

Can you clarify more @sudomaze ? You can run pre-commit with bundle without pip

@yousef337
You can't. You will need to have pip and you will need to install pre-commit through pip. jekyll-pre-commit allows you to check jekyll files using pre-commit-like setup, but it isn't actually pre-commit. At least that is what I found out when someone was trying to test this on their machine when pre-commit was added to our setup.

You can use pre-commit from source without using pip, a small script will do, however, I think not using python may not be straightforward.

I don't think it would be good to introduce additional complexity in our setup. We will be able to add pre-commit to our setup in the next release.

For this release, I'm not sure if https://github.com/jish/pre-commit does not need python.

You can try this out. If it works, then we can add it to this release.

It works, but I think we may need to change the config yaml file for pre-commit. I will create a pr for it if I found it better than what we currently have

What is the status of this?

@zaidalyafeai Currently, there are some native tools that run without python, however, most of what I encountered is not a better substitution to the current setup.

I am not the best to talk about this @MagedSaeed, any ideas? Do we just close this issue?