aboutsummaryrefslogtreecommitdiffstats
path: root/.pre-commit-config.yaml
blob: 8a3c787684a84995513ee64504a1e936e1d23ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: local
    hooks:
      - id: pipenv
        name: Install pipenv
        entry: bash -c 'pipenv install --skip-lock --dev'
        language: system
        pass_filenames: false
        always_run: true
        fail_fast: true
      - id: flake8
        name: Check PEP8 compliance (flake8)
        # Disable E203 for compatibility with blackformatter, and W503 as it goes against PEP8
        # Disable checks that are not relevant to this patch, they will be introduced later
        # - pathlib checks PLXXX
        entry: pipenv run python3 -m flake8 --max-line-length=99 --ignore=E203,E501,W503,PL100,PL104,PL106,PL107,PL110,PL112,PL113,PL114,PL115,PL116,PL117,PL118,PL120,PL123
        language: system
        types: [python]
        fail_fast: true
      - id: isort
        name: Sort imports (isort)
        entry: pipenv run python3 -m isort --line-length 99 --profile black --src packaging-tools
        language: system
        types: [python]
        fail_fast: true
      - id: mypy
        name: Check types (mypy)
        entry: pipenv run python3 -m mypy --strict
        language: system
        types: [python]
        fail_fast: true
      - id: pylint
        name: Analyze code (pylint)
        # Disabled:
        # Missing docstrings: C0114,C0115,C0116
        # Line too long: C0301
        # Need refactoring: C0302,R0201,R0902,R0903,R0904,R0912,R0913,R0914,R0915
        # Duplicate code: R0801
        # TODO comments: W0511
        # Too general exceptions: W0703, W0719
        # Checkers removed in some newer versions of pylint: R0022
        entry: pipenv run python3 -m pylint -j 0 --disable=C0114,C0115,C0116,C0301,C0302,R0201,R0801,R0902,R0903,R0904,R0912,R0913,R0914,R0915,W0511,W0703,W0719,R0022
        language: system
        types: [python]
        fail_fast: true
      - id: pytest
        name: Run unit tests (pytest)
        # Imports in unit tests failing as packaging-tools is not a valid Python package name
        # Change dir to packaging-tools and append to PYTHONPATH environment variable as a workaround
        # Run unit tests concurrently utilizing pytest-xdist module to pytest
        entry: bash -c 'cd packaging-tools && export PYTHONPATH=$(pwd) && pipenv run python3 -m pytest -n auto'
        language: system
        pass_filenames: false
        always_run: true
        fail_fast: true