diff --git a/pyproject.toml b/pyproject.toml index 50c7541..2633169 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,3 @@ -# [tool.black] -# line-length = 88 -# target-version = ['py38', 'py39', 'py310', 'py311'] -# include = '\.pyi?$' -# exclude = ''' -# /( -# \.git -# | \.hg -# | \.tox -# | \.venv -# | \.eggs -# | \.cache -# | build -# | __pycache__ -# | dist -# | \.* - -# )/ -# ''' - -# [tool.isort] -# # See https://black.readthedocs.io/en/stable/compatible_configs.html -# profile = "black" -# src_paths = ["wsgidav", "tests"] - - [tool.ruff] # Decrease the maximum line length to 79 characters. # line-length = 79 @@ -31,8 +5,6 @@ target-version = "py38" src = ["wsgidav", "tests"] -[tool.ruff.lint.isort] -known-first-party = ["wsgidav", "tests"] [tool.ruff.lint] select = [ @@ -47,6 +19,7 @@ select = [ # "C", # codespell # "SIM", # ] + ignore = [ # We need the old syntax for python <= 3.9 "UP006", # Use `list` instead of `List` for type annotations (since Py39) @@ -61,11 +34,64 @@ ignore = [ "UP031", # Use format specifiers instead of percent format ] -# [tool.ruff.pydocstyle] -# convention = "google" +[tool.ruff.lint.isort] +known-first-party = ["wsgidav", "tests"] + [tool.codespell] skip = '.git,*.pdf,*.svg,*.lock,*.css,logs' check-hidden = true # ignore-regex = '' # ignore-words-list = '' + + +# --- Pytest and Coverage Settings --------------------------------------------- +[tool.pytest.ini_options] +# addopts = "-ra -q --cov=wsgidav" + +testpaths = [ + # ".", + "tests/*.py" +] + +markers = [ + "benchmarks: include slow benchmarks (enable with '-m benchmarks')", + # "slow: marks tests as slow (deselect with '-m \"not slow\"')", + # "serial", +] + +[tool.coverage.run] +# branch = true +omit = [ + "tests/*", + "setup.py", + "wsgidav/prop_man/couch_property_manager.py", + "wsgidav/prop_man/mongo_property_manager.py", + "wsgidav/samples/*", + "wsgidav/server/run_reloading_server.py", + "wsgidav/server/server_sample.py", +] + +[tool.coverage.report] +precision = 2 +# show_missing = true +sort = "Name" +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] + +exclude_also = [ + # 1. Exclude an except clause of a specific form: + # "except ValueError:\\n\\s*assume\\(False\\)", + # 2. Comments to turn coverage on and off: + # "no cover: start(?s:.)*?no cover: stop", + # 3. A pragma comment that excludes an entire file: + # "\\A(?s:.*# pragma: exclude file.*)\\Z", + "\\A(?s:.*# pragma: exclude-file-from-coverage.*)\\Z", + ] + +[tool.coverage.html] +directory = "build/coverage" diff --git a/setup.cfg b/setup.cfg index 2f35a1e..f740290 100644 --- a/setup.cfg +++ b/setup.cfg @@ -98,40 +98,7 @@ ignore = docs/sphinx-build docs/sphinx-build/* + [aliases] # TODO: this breaks 'setup.py test' which is ought to run the Tox-command: #test = pytest - -# isort is configured in pyproject.toml: [tool.isort] -# [isort] - -# --- Coverage Settings -------------------------------------------------------- - -[coverage:run] -branch = True -omit = - tests/* - wsgidav/prop_man/couch_property_manager.py - wsgidav/prop_man/mongo_property_manager.py - wsgidav/samples/* - wsgidav/server/run_reloading_server.py - wsgidav/server/server_sample.py - -[coverage:report] -precision = 2 -; show_missing = True -sort = Name -exclude_lines = - pragma: no cover - if __name__ == .__main__.: - -[coverage:html] -directory = build/coverage - -# --- PyTest Settings ---------------------------------------------------------- - -[tool:pytest] -addopts = -testpaths = - . - tests diff --git a/tox.ini b/tox.ini index 4b15eac..a39f1dd 100644 --- a/tox.ini +++ b/tox.ini @@ -79,7 +79,7 @@ commands = # https://github.com/pytest-dev/pytest-html/issues/336#issuecomment-1546864331 coverage html --directory=build --ignore-errors ; coverage xml - coverage report --fail-under=30.0 --skip-empty --ignore-errors + coverage report --fail-under=40.0 --skip-empty --ignore-errors [testenv:mypy] @@ -90,6 +90,7 @@ changedir = {toxinidir} commands = mypy wsgidav tests + [testenv:lint] skip_install = true deps = @@ -99,19 +100,6 @@ commands = ruff check wsgidav tests setup.py ruff format --check wsgidav tests setup.py -; [testenv:check] -; description = Check Black formatting compliance and add flake8-bugbear checks -; skip_install = true -; deps = -; black ~=24.3 -; isort -; {[testenv:lint]deps} -; changedir = {toxinidir} -; commands = -; {[testenv:lint]commands} -; isort --check-only --profile black wsgidav tests setup.py -; black --check --diff wsgidav tests setup.py - [testenv:format] description = Reformat python code using ruff (Black, isort, and pyupgrade) @@ -124,18 +112,18 @@ commands = {[testenv:lint]commands} -[testenv:upgrade] -description = Upgrade Python syntax to least supported version -deps = - {[testenv:format]deps} - pyupgrade -allowlist_externals: - bash -changedir = {toxinidir} -commands = - # Needs bash-style file pattern expansion: - bash -ec 'pyupgrade --py37-plus --exit-zero-even-if-changed wsgidav/*.py tests/*.py setup.py' - {[testenv:format]commands} +; [testenv:upgrade] +; description = Upgrade Python syntax to least supported version +; deps = +; {[testenv:format]deps} +; pyupgrade +; allowlist_externals: +; bash +; changedir = {toxinidir} +; commands = +; # Needs bash-style file pattern expansion: +; bash -ec 'pyupgrade --py37-plus --exit-zero-even-if-changed wsgidav/*.py tests/*.py setup.py' +; {[testenv:format]commands} [testenv:docs] @@ -175,15 +163,3 @@ deps = commands = # http://www.sphinx-doc.org/en/master/man/sphinx-build.html python setup_bdist_msi.py bdist_msi - - -# [testenv:clean] -# commands = -# coverage erase - - -# [testenv:stats] -# commands = -# coverage combine -# coverage report -# coverage html