Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ steps:
from_secret: email_password
from: technical@dessia.tech

- name: check black formatting
image: python:3.9
commands:
- pip install black[jupyter]==23.1.0
- bash code_black.sh

- name: check code complexity
image: dessia/python-ci:3.9
commands:
- pip install pylint==2.16.1 pydocstyle==6.3.0 pre-commit shellcheck-py cython-lint pyenchant==3.2.2
- pip install pylint==2.16.1 pydocstyle==6.3.0 pre-commit shellcheck-py cython-lint pyenchant==3.2.2 black[jupyter]
- python code_pylint.py
- python code_pydocstyle.py
- pre-commit run -a
Expand Down
2 changes: 1 addition & 1 deletion .pep8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pycodestyle]
max_line_length = 120
ignore = E402, E722, E126, E731
ignore = E402, E722, E126, E731, E203
recursive = true
aggressive = 1

Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# to enable run `pip install pre-commit && pre-commit install`

repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
language_version: python3.9
args: [-l, "120"]

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.10.1
hooks:
Expand Down
18 changes: 18 additions & 0 deletions code_black.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# check black formatting on all files

if black --check .; then
echo -e "\nBlack found no formatting errors."
else
echo -e "\nBlack found formatting errors."

echo "Please run 'pre-commit run -a' to format the code (install pre-commit with pip)"

echo -e "\nAlternatively, you can run 'black .' (black v23.1.0) in source directory to format the code."
echo "You can run 'black --check --diff --color .' to see the difference with expected formatting."

echo -e "\nNote: Black is configurated in 'pyproject.toml' to have a 120 character line length."
echo "It is equivalent than using the 'l120' argument: 'black -l120 .'"

exit 1
fi
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[build-system]
requires = ["setuptools", "Cython"]

[tool.black]
line-length = 120
exclude = 'venv'