Spaces:
Runtime error
Runtime error
Commit
•
008db5c
1
Parent(s):
b3b602a
chore: implementing linting with pylint, black and updating ci
Browse files- .github/workflows/python-app.yml +2 -9
- .gitignore +2 -1
- .pre-commit-config.yaml +24 -0
- pyproject.toml +55 -0
- requirements.txt +3 -0
.github/workflows/python-app.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
2 |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
3 |
|
4 |
-
name: Python
|
5 |
|
6 |
on:
|
7 |
push:
|
@@ -27,14 +27,7 @@ jobs:
|
|
27 |
- name: Install dependencies
|
28 |
run: |
|
29 |
python -m pip install --upgrade pip
|
30 |
-
pip install
|
31 |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
32 |
- name: Lint with flake8
|
33 |
run: |
|
34 |
-
# stop the build if there are Python syntax errors or undefined names
|
35 |
-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
36 |
-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
37 |
-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
38 |
-
- name: Test with pytest
|
39 |
-
run: |
|
40 |
-
pytest
|
|
|
1 |
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
2 |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
3 |
|
4 |
+
name: Python Install and Linting
|
5 |
|
6 |
on:
|
7 |
push:
|
|
|
27 |
- name: Install dependencies
|
28 |
run: |
|
29 |
python -m pip install --upgrade pip
|
30 |
+
pip install pylint black
|
31 |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
32 |
- name: Lint with flake8
|
33 |
run: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
/.env/
|
2 |
-
__pycache__/
|
|
|
|
1 |
/.env/
|
2 |
+
__pycache__/
|
3 |
+
/start-venv.sh
|
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v2.3.0
|
4 |
+
hooks:
|
5 |
+
- id: check-yaml
|
6 |
+
- id: end-of-file-fixer
|
7 |
+
- id: trailing-whitespace
|
8 |
+
- repo: https://github.com/psf/black-pre-commit-mirror
|
9 |
+
rev: 23.12.1
|
10 |
+
hooks:
|
11 |
+
- id: black
|
12 |
+
language_version: python3.11
|
13 |
+
- repo: local
|
14 |
+
hooks:
|
15 |
+
- id: pylint
|
16 |
+
name: pylint
|
17 |
+
entry: pylint
|
18 |
+
language: system
|
19 |
+
types: [python]
|
20 |
+
args:
|
21 |
+
[
|
22 |
+
"-rn", # Only display messages
|
23 |
+
"-sn", # Don't display the score
|
24 |
+
]
|
pyproject.toml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[tool.black]
|
2 |
+
line-length = 88
|
3 |
+
include = '\.pyi?$'
|
4 |
+
exclude = '''
|
5 |
+
/(
|
6 |
+
\.eggs
|
7 |
+
| \.git
|
8 |
+
| \.hg
|
9 |
+
| \.mypy_cache
|
10 |
+
| \.tox
|
11 |
+
| \.venv
|
12 |
+
| _build
|
13 |
+
| buck-out
|
14 |
+
| build
|
15 |
+
| dist
|
16 |
+
)/
|
17 |
+
'''
|
18 |
+
|
19 |
+
[tool.pylint.messages_control]
|
20 |
+
disable = [
|
21 |
+
"arguments-differ",
|
22 |
+
"attribute-defined-outside-init",
|
23 |
+
"blacklisted-name",
|
24 |
+
"duplicate-code",
|
25 |
+
"fixme",
|
26 |
+
"import-error",
|
27 |
+
"invalid-name",
|
28 |
+
"no-member",
|
29 |
+
"no-name-in-module",
|
30 |
+
"protected-access",
|
31 |
+
"stop-iteration-return",
|
32 |
+
"too-few-public-methods",
|
33 |
+
"too-many-arguments",
|
34 |
+
"too-many-branches",
|
35 |
+
"too-many-instance-attributes",
|
36 |
+
"too-many-lines",
|
37 |
+
"too-many-locals",
|
38 |
+
"too-many-return-statements",
|
39 |
+
"too-many-statements",
|
40 |
+
"abstract-method",
|
41 |
+
"chained-comparison",
|
42 |
+
"eval-used",
|
43 |
+
"exec-used",
|
44 |
+
"expression-not-assigned",
|
45 |
+
"global-statement",
|
46 |
+
"missing-docstring",
|
47 |
+
"redefined-argument-from-local",
|
48 |
+
"redefined-outer-name",
|
49 |
+
"reimported",
|
50 |
+
"too-many-ancestors",
|
51 |
+
"unexpected-special-method-signature",
|
52 |
+
]
|
53 |
+
|
54 |
+
[tool.pylint.format]
|
55 |
+
max-line-length = "88"
|
requirements.txt
CHANGED
@@ -8,3 +8,6 @@ huggingface_hub~=0.19.4
|
|
8 |
fastapi~=0.104.1
|
9 |
uvicorn~=0.24.0
|
10 |
tinydb~=4.8.0
|
|
|
|
|
|
|
|
8 |
fastapi~=0.104.1
|
9 |
uvicorn~=0.24.0
|
10 |
tinydb~=4.8.0
|
11 |
+
black~=23.12.0
|
12 |
+
pylint~=3.0.0
|
13 |
+
pre-commit
|