-
Notifications
You must be signed in to change notification settings - Fork 4
/
.pre-commit-config.yaml
33 lines (33 loc) · 1.38 KB
/
.pre-commit-config.yaml
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
repos:
- repo: https://github.com/Exabyte-io/pre-commit-hooks
rev: 2023.6.13
hooks:
- id: ruff
exclude: ^src/py/mat3ra/esse/data|^src/py/mat3ra/esse/models
- id: black
exclude: ^src/py/mat3ra/esse/data|^src/py/mat3ra/esse/models
- repo: local
hooks:
# Note: only python 3.8.12 is tested for the model generation
- id: generate-python-modules
name: Regenerate data modules classes from static assets
# yamllint disable rule:line-length
entry: |
bash -c 'if [ "$(git diff --cached --name-only | grep "schema/")" ]; then echo "Skipping model generation because schemas were not changed."; exit 0; fi && \
datamodel-codegen \
--input ./dist/js/schema/ \
--input-file-type jsonschema \
--output ./dist/py \
--output-model-type pydantic_v2.BaseModel \
--use-field-description \
--use-double-quotes \
--enable-version-header \
--use-title-as-name \
--class-name ESSE \
--disable-timestamp && \
# Move 3rd party modules to a separate directory with a PEP8 compliant name
rm -rf ./dist/py/third_party && \
mv ./dist/py/3pse ./dist/py/third_party'
language: system
pass_filenames: false
verbose: true