|
| 1 | +repos: |
| 2 | + # Prevents committing directly branches named 'main' and 'master'. |
| 3 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 4 | + rev: v4.4.0 |
| 5 | + hooks: |
| 6 | + - id: no-commit-to-branch |
| 7 | + name: Prevent main branch commits |
| 8 | + description: Prevent the user from committing directly to the primary branch. |
| 9 | + - id: check-added-large-files |
| 10 | + name: Check for large files |
| 11 | + description: Prevent the user from committing very large files. |
| 12 | + args: ['--maxkb=500'] |
| 13 | + # Verify that pyproject.toml is well formed |
| 14 | + - repo: https://github.com/abravalheri/validate-pyproject |
| 15 | + rev: v0.12.1 |
| 16 | + hooks: |
| 17 | + - id: validate-pyproject |
| 18 | + name: Validate pyproject.toml |
| 19 | + description: Verify that pyproject.toml adheres to the established schema. |
| 20 | + # Verify that GitHub workflows are well formed |
| 21 | + - repo: https://github.com/python-jsonschema/check-jsonschema |
| 22 | + rev: 0.28.0 |
| 23 | + hooks: |
| 24 | + - id: check-github-workflows |
| 25 | + args: ["--verbose"] |
| 26 | + # Automatically sort the imports used in .py files |
| 27 | + - repo: https://github.com/pycqa/isort |
| 28 | + rev: 5.12.0 |
| 29 | + hooks: |
| 30 | + - id: isort |
| 31 | + name: Run isort |
| 32 | + description: Sort and organize imports in .py and .pyi files. |
| 33 | + types_or: [python, pyi] |
| 34 | + # Analyze the tests code style and report code that doesn't adhere. |
| 35 | + - repo: local |
| 36 | + hooks: |
| 37 | + - id: pylint |
| 38 | + name: pylint (python files in tests/ and benchmarks/) |
| 39 | + entry: pylint |
| 40 | + language: system |
| 41 | + types: [python] |
| 42 | + files: ^(tests|benchmarks)/ |
| 43 | + args: |
| 44 | + [ |
| 45 | + "-rn", # Only display messages |
| 46 | + "-sn", # Don't display the score |
| 47 | + ] |
| 48 | + # Analyze the code style and report code that doesn't adhere. |
| 49 | + - repo: https://github.com/psf/black |
| 50 | + rev: 23.7.0 |
| 51 | + hooks: |
| 52 | + - id: black-jupyter |
| 53 | + name: Format code using black |
| 54 | + types_or: [python, pyi, jupyter] |
| 55 | + # It is recommended to specify the latest version of Python |
| 56 | + # supported by your project here, or alternatively use |
| 57 | + # pre-commit's default_language_version, see |
| 58 | + # https://pre-commit.com/#top_level-default_language_version |
| 59 | + language_version: python3.10 |
| 60 | + # Make sure Sphinx can build the documentation without issues. |
| 61 | + - repo: local |
| 62 | + hooks: |
| 63 | + - id: sphinx-build |
| 64 | + name: Build documentation with Sphinx |
| 65 | + entry: sphinx-build |
| 66 | + language: system |
| 67 | + always_run: true |
| 68 | + exclude_types: [file, symlink] |
| 69 | + args: |
| 70 | + [ |
| 71 | + "-T", # Show full trace back on exception |
| 72 | + "-E", # Don't use saved env. always read all files. |
| 73 | + "-b", # Flag to select which builder to use |
| 74 | + "html", # Use the HTML builder |
| 75 | + "-d", # Flag for cached environment and doctrees |
| 76 | + "./docs/_build/doctrees", # directory |
| 77 | + "./docs", # Source directory of documents |
| 78 | + "./_readthedocs", # Output directory for rendered documents. |
| 79 | + ] |
| 80 | + # Run unit tests, verify that they pass. Note that coverage is run against |
| 81 | + # the ./src directory here because that is what will be committed. In the |
| 82 | + # github workflow script, the coverage is run against the installed package |
| 83 | + # and uploaded to Codecov by calling pytest like so: |
| 84 | + # `python -m pytest --cov=<package_name> --cov-report=xml` |
| 85 | + - repo: local |
| 86 | + hooks: |
| 87 | + - id: pytest-check |
| 88 | + name: Run unit tests |
| 89 | + description: Run unit tests with pytest. |
| 90 | + entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi" |
| 91 | + language: system |
| 92 | + pass_filenames: false |
| 93 | + always_run: true |
0 commit comments