Skip to content

Commit 3103017

Browse files
authored
Merge pull request #4 from ESGF/feature/poetry-checks
Feature/poetry checks
2 parents 22566bc + d5463e4 commit 3103017

File tree

5 files changed

+501
-473
lines changed

5 files changed

+501
-473
lines changed

.github/workflows/check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
- name: Install Dependencies
4747
run: |
4848
poetry env use 3.12
49+
- name: Check Poetry
50+
run: |
51+
poetry check --lock
4952
- name: Run black
5053
run: |
5154
poetry install --only black

.pre-commit-config.yaml

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
11
fail_fast: true
22
repos:
3-
- repo: local
4-
hooks:
5-
- id: black
6-
name: black
7-
entry: poetry run black
8-
language: system
9-
types: [file, python]
10-
- id: isort
11-
name: isort
12-
entry: poetry run isort
13-
language: system
14-
types: [file, python]
15-
- id: ruff
16-
name: ruff
17-
entry: poetry run ruff check --fix
18-
language: system
19-
types: [file, python]
20-
- id: bandit
21-
name: bandit
22-
entry: poetry run bandit -c pyproject.toml -r .
23-
language: system
24-
types: [file, python]
25-
- id: xenon
26-
name: xenon
27-
entry: bash -c "poetry run xenon -a $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['average'])\") -b $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['block'])\") -m $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['module'])\") . "
28-
language: system
29-
types: [file, python]
30-
- id: mypy
31-
name: mypy
32-
entry: poetry run mypy --no-namespace-packages --exclude esgf_playground_utils/models/__init__.py
33-
language: system
34-
types: [ file, python ]
3+
- repo: https://github.com/python-poetry/poetry
4+
rev: '1.8.3' # add version here
5+
hooks:
6+
- id: poetry-check
7+
- id: poetry-lock
8+
- repo: local
9+
hooks:
10+
- id: black
11+
name: black
12+
entry: poetry run black
13+
language: system
14+
types: [ file, python ]
15+
- id: isort
16+
name: isort
17+
entry: poetry run isort
18+
language: system
19+
types: [ file, python ]
20+
- id: ruff linter
21+
name: ruff lint
22+
entry: poetry run ruff check --fix
23+
language: system
24+
types: [ file, python ]
25+
- id: bandit
26+
name: bandit
27+
entry: poetry run bandit -c pyproject.toml -r .
28+
language: system
29+
types: [ file, python ]
30+
- id: xenon
31+
name: xenon
32+
entry: bash -c "poetry run xenon -a $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['average'])\") -b $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['block'])\") -m $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['module'])\") . "
33+
language: system
34+
types: [ file, python ]
35+
- id: mypy
36+
name: mypy
37+
entry: poetry run mypy --no-namespace-packages --exclude esgf_playground_utils/models/__init__.py
38+
language: system
39+
types: [ file, python ]
40+
- id: bandit
41+
name: bandit
42+
entry: poetry run bandit -c pyproject.toml -r .
43+
language: system
44+
types: [ file, python ]
45+
- id: xenon
46+
name: xenon
47+
entry: bash -c "poetry run xenon -a $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['average'])\") -b $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['block'])\") -m $(poetry run python -c \"import tomllib; f = open('pyproject.toml','rb') ; data = tomllib.load(f); f.close(); print(data['tool']['quality']['mccabe']['module'])\") . "
48+
language: system
49+
types: [ file, python ]
50+
- id: mypy
51+
name: mypy
52+
entry: poetry run mypy --no-namespace-packages --exclude esgf_playground_utils/models/__init__.py
53+
language: system
54+
types: [ file, python ]

CONTRIBUTING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ foo@bar:~$ poetry run install pre-commit
2828

2929
When you commit, the following checks will be run:
3030

31-
- black[^1] (python style formatter)
32-
- isort[^1] (python import order checker)
33-
- ruff[^1] (python linter)
34-
- mypy (python static type analysis)
35-
- bandit (pythin SAST analyis)
36-
- xenon (McCabe cyclomatc complexity analysis)
31+
- poetry-check (checks the conformity of the pyproject.toml and poetry.lock file)
32+
- poetry-lock[^1] (ensures an up-to-date lock file)
33+
- black[^1] (python style formatter)
34+
- isort[^1] (python import order checker)
35+
- ruff linter[^1] (python linter)
36+
- mypy (python static type analysis)
37+
- bandit (python SAST analyis)
38+
- xenon (McCabe cyclomatc complexity analysis)
3739

3840
You can disable the `pre-commit hooks` per commit with the flag `--no-verify` however all checks will be preformed in the CI.
3941

0 commit comments

Comments
 (0)