diff --git a/Makefile b/Makefile index 177584c..7be5ae8 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,9 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT" help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) +venvexists: ## helper to check if a virtual environment exists + @test -x .venv/bin/python || { echo "No virtual environment found, please run 'make devenv'"; exit 1; } + clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts clean-build: ## remove build artifacts @@ -50,44 +53,36 @@ clean-test: ## remove test and coverage artifacts rm -f .coverage rm -fr htmlcov/ -lint: ## reformat with black and check style with flake8 - isort ordr3 - isort tests - black ordr3 tests - flake8 ordr3 tests - -test: lint ## run tests quickly, stop on first error - pytest tests -x -l --last-failed --disable-warnings -m "not fun" - -testfun: lint ## run functional tests, stop on first error - pytest tests -x -l -m "fun" +lint: venvexists ## reformat and check style with ruff + .venv/bin/ruff format ordr3 tests + .venv/bin/ruff check ordr3 tests -testall: lint ## run all tests - pytest tests -l +test: lint ## run tests quickly, stop on first error + .venv/bin/pytest tests --stepwise --disable-warnings -m "not functional" -coverage: lint ## functional test suite, check code coverage and open coverage report - pytest tests --cov=ordr3 -l -m "fun" - coverage html - $(BROWSER) htmlcov/index.html +testfunctional: lint ## run functional tests, stop on first error + .venv/bin/pytest tests --stepwise -m "functional" -coverall: lint ## full test suite, check code coverage and open coverage report - pytest tests --cov=ordr3 -l - coverage html - $(BROWSER) htmlcov/index.html +testall: lint ## run all tests + .venv/bin/pytest tests -tox: ## run fully isolated tests with tox - tox +tox: venvexists ## run fully isolated tests with tox + .venv/bin/tox -install: ## install updated project.toml with flint - flit install --pth-file +install: venvexists ## install updated project.toml + .venv/bin/pip3 install --upgrade pip wheel + .venv/bin/pip3 install -e ".[dev,docs,test]" -devenv: ## setup development environment +prepareenv: ## helper to create virtual environment and install basic packages + rm -fr .venv/ python3 -m venv --prompt ordr3 .venv - .venv/bin/pip3 install --upgrade pip - .venv/bin/pip3 install "flit>3.2" - .venv/bin/flit install --pth-file + .venv/bin/pip3 install --upgrade pip wheel + .venv/bin/pip3 install -e ".[dev,test]" + +devenv: prepareenv ## setup development environment including precommit hooks + .venv/bin/pre-commit install --install-hooks -repo: devenv ## complete project setup with development environment and git repo +repo: prepareenv ## complete project setup with development environment and git repo git init . git branch -m main git add . diff --git a/pyproject.toml b/pyproject.toml index 70cfc57..5424559 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,45 +52,89 @@ main = "ordr3:main" test = [ "pytest >=4.0.0", "pytest-cov", + "pytest-icdiff", "pytest-mock", "pytest-randomly", "tox", "webtest", ] dev = [ - "black", - "flake8", - "flake8-comprehensions", - "flake8-bandit", - "isort >= 5.0.0", + "ruff", "keyring", "pre-commit", ] -[tool.black] -line-length = 79 -target-version = ['py37','py38', 'py39'] -include = '\.pyi?$' -extend-exclude = ''' -# A regex preceded with ^/ will apply only to files and directories -# in the root of the project. -^/.git -^/.tox -^/.venv -^/.build -^/.dist -''' - -[tool.isort] -line_length=79 -multi_line_output=3 -length_sort="True" -include_trailing_comma="True" [tool.pytest.ini_options] markers = [ - "fun: marks tests as functional (deselect with '-m \"not fun\"')", + "functional: marks tests as functional (deselect with '-m \"not functional\"')", ] addopts = [ "--strict-markers", + "--strict-config", + "--showlocals", + "-ra", ] + +[tool.ruff] +# see https://docs.astral.sh/ruff/configuration/ + +line-length = 80 +indent-width = 4 + +fix = true + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +fixable = ["ALL"] +select = ["ALL"] +ignore = [ + # currently ignored when moving to ruff + "ANN", + "DTZ", + "RUF", + "A002", + "ARG005", + "FBT003", + "FLY002", + "N802", + "N806", + "PLR2004", + "PT006", + "PYI024", + "RET504", + "SIM117", + "TID252", + "UP031", + + # ignored for now, should be activated in the future + # docstrings + "D", + + # don't complain about not annotating self or cls + "ANN101", + "ANN102", + + # ignored, "ruff format" will handle this + "COM812", + "ISC001", + + # ignored, due to Windows / WSL2 setup + # flake8-executable + "EXE", +] + +[tool.ruff.lint.pydocstyle] +convention = "pep257" # Accepts: "google", "numpy", or "pep257". + +[tool.ruff.lint.per-file-ignores] +# see https://github.com/charliermarsh/ruff +"tests/*" = ["FBT003", "INP001", "PLR2004", "S101", "SLF001", "ANN"] +"noxfile.py" = ["ANN"] + + +[tool.ruff.format] +indent-style = "space" +