From 75c36c9b51c48b01e0952245a5055a0c5ac585e9 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Fri, 15 Apr 2022 16:45:12 +0200 Subject: [PATCH] Use darker --- .github/workflows/pytest.yml | 5 ----- Makefile | 10 --------- pyproject.toml | 41 ++++++++++++++++++++++++++---------- tests/test_lint.py | 13 ------------ 4 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 tests/test_lint.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 1acd932..c2ab5f2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -37,8 +37,3 @@ jobs: - name: 'Upload coverage report' run: bash <(curl -s https://codecov.io/bash) - - - name: 'Run linters' - if: matrix.python-version == '3.8' - run: | - make lint diff --git a/Makefile b/Makefile index 650fd20..e390dc1 100644 --- a/Makefile +++ b/Makefile @@ -28,16 +28,6 @@ update: install-poetry ## update the sources and installation and generate "con poetry update poetry export -f requirements.txt --output conf/requirements.txt -lint: ## Run code formatters and linter - poetry run flynt --fail-on-change --line-length=${MAX_LINE_LENGTH} . - poetry run isort --check-only . - poetry run flake8 . - -fix-code-style: ## Fix code formatting - poetry run flynt --line-length=${MAX_LINE_LENGTH} . - poetry run black --verbose --safe --line-length=${MAX_LINE_LENGTH} --skip-string-normalization . - poetry run isort . - tox-listenvs: check-poetry ## List all tox test environments poetry run tox --listenvs diff --git a/pyproject.toml b/pyproject.toml index 1438650..047ed78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,11 +23,14 @@ tox = "*" pytest = "*" pytest-cov = "*" pytest-django = "*" +pytest-darker = "*" # https://github.com/akaihola/pytest-darker +pytest-flake8 = "*" +pytest-isort = "*" coveralls = "*" isort = "*" flake8 = "*" flynt = "*" -black = "*" +darker = "*" # https://github.com/akaihola/darker pyupgrade = "*" [build-system] @@ -35,18 +38,32 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +[tool.darker] +src = ['.'] +revision = "origin/master..." +line_length = 100 +verbose = true +skip_string_normalization = true +diff = false +check = false +stdout = false +isort = true +lint = [ + "flake8", +] +log_level = "INFO" + + +[tool.flynt] +line_length = 100 + + [tool.isort] # https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format atomic=true -line_length=120 -case_sensitive=false +profile='black' +line_length=100 skip_glob=["*/htmlcov/*","*/migrations/*"] -multi_line_output=3 -include_trailing_comma=true -known_first_party=["for_runners"] -no_lines_before="LOCALFOLDER" -default_section="THIRDPARTY" -sections=["FUTURE","STDLIB","THIRDPARTY","FIRSTPARTY","LOCALFOLDER"] lines_after_imports=2 @@ -62,7 +79,6 @@ norecursedirs = ".* .git __pycache__ conf coverage* dist htmlcov" # --full-trace # -p no:warnings addopts = """ - --import-mode=importlib --reuse-db --nomigrations --cov=. @@ -71,12 +87,15 @@ addopts = """ --cov-report xml --no-cov-on-fail --showlocals + --darker + --flake8 + --isort --doctest-modules --failed-first --last-failed-no-failures all --new-first """ - +# TODO: --mypy [tool.tox] # https://tox.readthedocs.io/en/latest/example/basic.html#pyproject-toml-tox-legacy-ini diff --git a/tests/test_lint.py b/tests/test_lint.py deleted file mode 100644 index 003dc76..0000000 --- a/tests/test_lint.py +++ /dev/null @@ -1,13 +0,0 @@ -import shutil -import subprocess -from pathlib import Path - - -BASE_PATH = Path(__file__).parent.parent - - -def test_lint(): - assert Path(BASE_PATH, 'Makefile').is_file() - make_bin = shutil.which('make') - assert make_bin is not None - subprocess.check_call([make_bin, 'lint'], cwd=BASE_PATH)