kopia lustrzana https://github.com/wagtail/wagtail
Switch to ruff for flake8 / isort code checking (#10324)
rodzic
5b20ae5f83
commit
459fbb2cc9
|
@ -19,8 +19,7 @@ jobs:
|
|||
key: pipenv-v1-{{ checksum "setup.py" }}
|
||||
paths:
|
||||
- .venv
|
||||
- run: pipenv run flake8
|
||||
- run: pipenv run isort --check-only --diff .
|
||||
- run: pipenv run ruff check .
|
||||
- run: pipenv run black --target-version py37 --check --diff .
|
||||
- run: pipenv run semgrep --config .semgrep.yml --error .
|
||||
- run: git ls-files '*.html' | xargs pipenv run djhtml --check
|
||||
|
|
|
@ -8,19 +8,14 @@ repos:
|
|||
- id: black
|
||||
language_version: python3
|
||||
args: ['--target-version', 'py37']
|
||||
- repo: https://github.com/timothycrosley/isort
|
||||
# isort config is in setup.cfg
|
||||
rev: 5.6.4
|
||||
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: 'v0.0.261'
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
# flake8 config is in setup.cfg
|
||||
rev: 3.8.4
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies:
|
||||
- flake8-comprehensions
|
||||
- flake8-assertive
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.5.1
|
||||
hooks:
|
||||
|
|
9
Makefile
9
Makefile
|
@ -3,8 +3,8 @@
|
|||
help:
|
||||
@echo "clean-pyc - remove Python file artifacts"
|
||||
@echo "develop - install development dependencies"
|
||||
@echo "lint - check style with black, flake8, sort python with isort, indent html, and lint frontend css/js"
|
||||
@echo "format - enforce a consistent code style across the codebase, sort python files with isort and fix frontend css/js"
|
||||
@echo "lint - check style with black, ruff, sort python with ruff, indent html, and lint frontend css/js"
|
||||
@echo "format - enforce a consistent code style across the codebase, sort python files with ruff and fix frontend css/js"
|
||||
@echo "test - run tests"
|
||||
@echo "coverage - check code coverage"
|
||||
|
||||
|
@ -19,8 +19,7 @@ develop: clean-pyc
|
|||
|
||||
lint-server:
|
||||
black --target-version py37 --check --diff .
|
||||
flake8
|
||||
isort --check-only --diff .
|
||||
ruff check .
|
||||
semgrep --config .semgrep.yml --error .
|
||||
curlylint --parse-only wagtail
|
||||
git ls-files '*.html' | xargs djhtml --check
|
||||
|
@ -37,7 +36,7 @@ lint: lint-server lint-client lint-docs
|
|||
|
||||
format-server:
|
||||
black --target-version py37 .
|
||||
isort .
|
||||
ruff check . --fix
|
||||
git ls-files '*.html' | xargs djhtml -i
|
||||
|
||||
format-client:
|
||||
|
|
|
@ -10,7 +10,7 @@ run by `pre-commit` if that is configured.
|
|||
a text editor with [EditorConfig](https://editorconfig.org/) support to avoid indentation and
|
||||
whitespace issues. Python and HTML files use 4 spaces for indentation.
|
||||
|
||||
In addition, import lines should be sorted according to [isort](https://pycqa.github.io/isort/) 5.6.4 rules.
|
||||
In addition, import lines should be sorted according to [isort](https://pycqa.github.io/isort/) rules.
|
||||
If you have installed Wagtail's testing dependencies (`pip install -e '.[testing]'`), you can check your code by
|
||||
running `make lint`. You can also just check python related linting by running `make lint-server`.
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# D100: Missing docstring in public module
|
||||
# D101: Missing docstring in public class
|
||||
# D102: Missing docstring in public method
|
||||
# D103: Missing docstring in public function
|
||||
# D105: Missing docstring in magic method
|
||||
# N806: Variable in function should be lowercase
|
||||
# E501: Line too long
|
||||
ignore = ["D100","D101","D102","D103","D105","N806","E501"]
|
||||
exclude = ["wagtail/project_template/*","node_modules","venv",".venv"]
|
||||
line-length = 88
|
21
setup.cfg
21
setup.cfg
|
@ -1,31 +1,10 @@
|
|||
[bdist_wheel]
|
||||
python-tag = py3
|
||||
|
||||
[flake8]
|
||||
# D100: Missing docstring in public module
|
||||
# D101: Missing docstring in public class
|
||||
# D102: Missing docstring in public method
|
||||
# D103: Missing docstring in public function
|
||||
# D105: Missing docstring in magic method
|
||||
# W503: line break before binary operator (superseded by W504 line break after binary operator)
|
||||
# N806: Variable in function should be lowercase
|
||||
# E203: Whitespace before ':'
|
||||
# E501: Line too long
|
||||
ignore = D100,D101,D102,D103,D105,W503,N806,E203,E501
|
||||
exclude = wagtail/project_template/*,node_modules,venv,.venv
|
||||
max-line-length = 88
|
||||
|
||||
[doc8]
|
||||
ignore = D001
|
||||
ignore-path = _build,docs/_build
|
||||
|
||||
[isort]
|
||||
profile = black
|
||||
skip=migrations,project_template,node_modules,.git,__pycache__,LC_MESSAGES,venv,.venv,.tox
|
||||
blocked_extensions=rst,html,js,svg,txt,css,scss,png,snap,ts,tsx
|
||||
known_first_party=wagtail
|
||||
default_section=THIRDPARTY
|
||||
|
||||
[tool:pytest]
|
||||
django_find_project = false
|
||||
python_files=test_*.py
|
||||
|
|
7
setup.py
7
setup.py
|
@ -53,13 +53,8 @@ testing_extras = [
|
|||
# For coverage and PEP8 linting
|
||||
"coverage>=3.7.0",
|
||||
"black==22.3.0",
|
||||
"flake8>=3.6.0",
|
||||
"isort==5.6.4", # leave this pinned - it tends to change rules between patch releases
|
||||
"flake8-blind-except==0.1.1",
|
||||
"flake8-comprehensions==3.8.0",
|
||||
"flake8-print==5.0.0",
|
||||
"doc8==0.8.1",
|
||||
"flake8-assertive==2.0.0",
|
||||
"ruff==0.0.261",
|
||||
# For enforcing string formatting mechanism in source files
|
||||
"semgrep==1.3.0",
|
||||
# For templates linting
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -58,7 +58,3 @@ setenv =
|
|||
mssql: DATABASE_USER=sa
|
||||
mssql: DATABASE_PASSWORD=Password12!
|
||||
|
||||
[testenv:flake8]
|
||||
basepython=python3.7
|
||||
deps=flake8>=3.6.0
|
||||
commands=flake8
|
||||
|
|
Ładowanie…
Reference in New Issue