Skip to content

Commit 04c688a

Browse files
author
Thierry Loron
committed
feat: add ruff
1 parent 00d2df1 commit 04c688a

37 files changed

+224
-266
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@ jobs:
1717
python-version: ${{ matrix.python-version }}
1818
- name: Install dependencies
1919
run: |
20-
python -m pip install --upgrade pip wheel setuptools
21-
pip install flake8 pytest
22-
if [ -f requirements.dev.txt ]; then pip install -r requirements.dev.txt; fi
23-
- name: Lint with flake8
24-
run: |
25-
# stop the build if there are Python syntax errors or undefined names
26-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
28-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
20+
python -m pip install --upgrade pip
21+
pip install .[all]
22+
- name: Run pre-commit hook
23+
run: pre-commit run --all-files
2924
- name: Test with pytest
3025
run: |
3126
python -m pytest
3227
- name: Build python package
3328
run: |
34-
python setup.py sdist bdist_wheel
29+
python -m pip install --upgrade build
30+
python -m build
3531
- name: Deploy to PyPI
3632
if: success() && startsWith(github.ref, 'refs/tags') && matrix.python-version == '3.11'
3733
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ default_language_version:
22
python: python3
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v3.2.0
5+
rev: v4.6.0
66
hooks:
77
- id: check-ast
8-
- id: check-byte-order-marker
8+
- id: fix-byte-order-marker
99
- id: check-case-conflict
1010
- id: check-docstring-first
11-
- id: check-executables-have-shebangs
11+
- id: check-shebang-scripts-are-executable
1212
- id: check-json
1313
- id: check-yaml
1414
exclude: ^chart/
@@ -28,30 +28,12 @@ repos:
2828
args: ['--maxkb=500']
2929
- id: no-commit-to-branch
3030
args: ['--branch', 'master', '--branch', 'develop']
31-
- repo: https://github.com/psf/black
32-
rev: 21.12b0
31+
- repo: https://github.com/astral-sh/ruff-pre-commit
32+
rev: v0.5.2
3333
hooks:
34-
- id: black
35-
args: [--line-length=120]
36-
additional_dependencies: ['click==8.0.4']
37-
#- repo: https://github.com/pre-commit/mirrors-mypy
38-
# rev: 'v0.931'
39-
# hooks:
40-
# - id: mypy
41-
# args: [--ignore-missing-imports, --disallow-untyped-defs, --show-error-codes, --no-site-packages]
42-
# files: src
43-
- repo: https://github.com/PyCQA/flake8
44-
rev: 6.0.0
45-
hooks:
46-
- id: flake8
47-
exclude: ^tests/
48-
args: ['--ignore=E501,D2,D3,D4,D104,D100,D106,D107,W503,D105,E203', '--per-file-ignores=__init__.py:F401']
49-
additional_dependencies: [ flake8-docstrings, "flake8-bugbear==22.8.23" ]
50-
- repo: https://github.com/pre-commit/mirrors-isort
51-
rev: v5.4.2
52-
hooks:
53-
- id: isort
54-
args: ["--profile", "black", "-l", "120"]
34+
- id: ruff
35+
args: [--fix]
36+
- id: ruff-format
5537
- repo: https://github.com/asottile/pyupgrade
5638
rev: v2.7.2
5739
hooks:
@@ -62,8 +44,13 @@ repos:
6244
hooks:
6345
- id: blacken-docs
6446
additional_dependencies: [black==21.12b0]
47+
- repo: https://github.com/pypa/pip-audit
48+
rev: v2.7.3
49+
hooks:
50+
- id: pip-audit
51+
args: ["--skip-editable"]
6552
- repo: https://github.com/compilerla/conventional-pre-commit
66-
rev: v2.1.1
53+
rev: v3.3.0
6754
hooks:
6855
- id: conventional-pre-commit
6956
stages: [commit-msg]

pyproject.toml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "shapash"
7+
version = "2.6.0"
8+
authors = [
9+
{name = "Yann Golhen"},
10+
{name = "Sebastien Bidault"},
11+
{name = "Yann Lagre"},
12+
{name = "Maxime Gendre"},
13+
{name = "Thomas Bouché", email = "[email protected]"},
14+
{name = "Maxime Lecardonnel"},
15+
{name = "Guillaume Vignal"},
16+
]
17+
description = "Shapash is a Python library which aims to make machine learning interpretable and understandable by everyone."
18+
readme = "README.md"
19+
requires-python = ">3.8, <3.13"
20+
license = {text = "Apache Software License 2.0"}
21+
keywords = ["shapash"]
22+
classifiers = [
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"License :: OSI Approved :: Apache Software License",
29+
"Operating System :: OS Independent",
30+
]
31+
dependencies = [
32+
"plotly>=5.0.0",
33+
"matplotlib>=3.2.0",
34+
"numpy>1.18.0,<2",
35+
"pandas>=2.1.0",
36+
"shap>=0.45.0",
37+
"Flask>=1.0.4",
38+
"dash>=2.3.1",
39+
"dash-bootstrap-components>=1.1.0",
40+
"dash-core-components>=2.0.0",
41+
"dash-daq>=0.5.0",
42+
"dash-html-components>=2.0.0",
43+
"dash-renderer==1.8.3",
44+
"dash-table>=5.0.0",
45+
"nbformat>4.2.0",
46+
"numba>=0.53.1",
47+
"scikit-learn>=1.4.0",
48+
"category_encoders>=2.6.0",
49+
"scipy>=0.19.1",
50+
]
51+
52+
[project.optional-dependencies] # Optional
53+
report = [
54+
"nbconvert>=6.0.7",
55+
"papermill>=2.0.0",
56+
"jupyter-client>=7.4.0",
57+
"seaborn==0.12.2",
58+
"notebook",
59+
"Jinja2>=2.11.0",
60+
"phik",
61+
]
62+
xgboost = ["xgboost>=1.0.0"]
63+
lightgbm = ["lightgbm>=2.3.0"]
64+
catboost = ["catboost>=1.0.1"]
65+
lime = ["lime>=0.2.0.0"]
66+
67+
dev = ["pre-commit", "mypy", "ruff"]
68+
test = ["pytest", "pytest-cov"]
69+
mypy = ["mypy"]
70+
ruff = ["ruff"]
71+
doc = [
72+
"Sphinx==4.5.0",
73+
"sphinxcontrib-applehelp==1.0.2",
74+
"sphinxcontrib-devhelp==1.0.2",
75+
"sphinxcontrib-htmlhelp==2.0.0",
76+
"sphinxcontrib-jsmath==1.0.1",
77+
"sphinxcontrib-qthelp==1.0.3",
78+
"sphinxcontrib-serializinghtml==1.1.5",
79+
"nbsphinx==0.8.8",
80+
"sphinx_material==0.0.35",
81+
]
82+
83+
all = ["shapash[dev, test, mypy, ruff, report, xgboost, lightgbm, catboost, lime, doc]"]
84+
85+
[project.urls]
86+
Homepage = "https://github.com/MAIF/shapash"
87+
88+
[tool.setuptools]
89+
package-dir = {"" = "shapash"}
90+
91+
[tool.setuptools.packages.find]
92+
where = ["shapash"]
93+
94+
95+
[tool.setuptools.package-data]
96+
"shapash" = ["*.csv", "*json", "*.yml", "*.css", "*.js", "*.png"]
97+
98+
[tool.pytest.ini_options]
99+
pythonpath = ["."]
100+
testpaths = ["tests"]
101+
102+
[tool.mypy]
103+
exclude = ["tests", "tutorial"]
104+
ignore_missing_imports = true
105+
106+
[tool.ruff]
107+
line-length = 120
108+
exclude = [
109+
"tests",
110+
"docs",
111+
"tutorial",
112+
]
113+
114+
[tool.ruff.lint]
115+
select = [
116+
"E", # pycodestyle errors
117+
"F", # pyflakes
118+
"W", # pycodestyle warnings
119+
"A", # flake8-builtins
120+
"PLC", # pylint conventions
121+
"PLE", # pylint errors
122+
"PLW", # pylint warnings
123+
"UP", # pyupgrade
124+
"S", # flake8-bandit,
125+
"B", # flake8-bugbear
126+
"I", # isort
127+
"D", # pydocstyle
128+
"NPY", # NumPy-specific rules
129+
]
130+
ignore = ["E501", "D2", "D3", "D4", "D104", "D100", "D105", "D106", "D107", "S311"]
131+
exclude = ["tests/*", "*.ipynb"]
132+
133+
[tool.ruff.lint.per-file-ignores]
134+
"shapash/__init__.py" = ["F401"]
135+
"shapash/backend/__init__.py" = ["F401"]
136+
"shapash/backend/base_backend.py" = ["S101"]
137+
"shapash/backend/lime_backend.py" = ["PLW2901"]
138+
"shapash/data/data_loader.py" = ["S310", "B904"]
139+
"shapash/explainer/consistency.py" = ["PLW2901", "NPY002", "UP031", "E741"]
140+
"shapash/explainer/smart_explainer.py" = ["S104", "B904"]
141+
"shapash/explainer/smart_plotter.py" = ["PLW3301", "A001", "S101"]
142+
"shapash/explainer/smart_predictor.py" = ["S101", "B904", "E721"]
143+
"shapash/manipulation/summarize.py" = ["B028"]
144+
"shapash/plots/plot_line_comparison.py" = ["B028", "A001"]
145+
"shapash/plots/plot_scatter_prediction.py" = ["PLW0127", "PLW3301"]
146+
"shapash/report/__init__.py" = ["B904"]
147+
"shapash/report/plots.py" = ["A002"]
148+
"shapash/report/visualisation.py" = ["UP031"]
149+
"shapash/report/project_report.py" = ["S101", "S701"]
150+
"shapash/utils/columntransformer_backend.py" = ["PLW0127"]
151+
"shapash/utils/explanation_metrics.py" = ["S101"]
152+
"shapash/utils/io.py" = ["S301"]
153+
"shapash/webapp/utils/callbacks.py" = ["A002", "E721"]
154+
"shapash/webapp/utils/utils.py" = ["UP031"]
155+
"shapash/webapp/utils/MyGraph.py" = ["A002"]
156+
"shapash/webapp/smart_app.py" = ["A002", "S307", "E721", "A001"]
157+
"shapash/webapp/webapp_launch_DVF.py" = ["S104"]
158+
"shapash/webapp/webapp_launch.py" = ["S104", "S301"]

requirements.dev.txt

Lines changed: 0 additions & 43 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)