-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pyproject.toml to configure ruff
- Loading branch information
1 parent
b3f3c4d
commit e6ce3ea
Showing
8 changed files
with
100 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Testing tools configuration | ||
[tool.coverage.run] | ||
branch = true | ||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
log_cli_level = "INFO" | ||
|
||
# Formatting tools configuration | ||
[tool.black] | ||
line-length = 99 | ||
target-version = ["py38"] | ||
|
||
# Linting tools configuration | ||
[tool.ruff] | ||
line-length = 99 | ||
select = ["E", "W", "F", "C", "N", "D", "I001"] | ||
extend-ignore = [ | ||
"D203", | ||
"D204", | ||
"D213", | ||
"D215", | ||
"D400", | ||
"D404", | ||
"D406", | ||
"D407", | ||
"D408", | ||
"D409", | ||
"D413", | ||
] | ||
ignore = ["E501", "D107"] | ||
extend-exclude = ["__pycache__", "*.egg_info"] | ||
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]} | ||
|
||
[tool.ruff.mccabe] | ||
max-complexity = 10 | ||
|
||
[tool.codespell] | ||
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,59 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
|
||
[isort] | ||
profile = black | ||
|
||
# Copyright 2023 Canonical | ||
# See LICENSE file for licensing details. | ||
|
||
[tox] | ||
skipsdist = True | ||
envlist = lint,unit | ||
no_package = True | ||
skip_missing_interpreters = True | ||
env_list = format, lint, unit | ||
min_version = 4.0.0 | ||
|
||
[vars] | ||
cov_path = {toxinidir}/htmlcov | ||
src_path = {toxinidir}/src/ | ||
tst_path = {toxinidir}/tests/ | ||
upstream_path = {toxinidir}/upstream/ | ||
tst_data_path = {toxinidir}/tests/data/ | ||
all_path = {[vars]src_path} {[vars]tst_path} {[vars]upstream_path} | ||
|
||
|
||
[pytest] | ||
log_cli = 1 | ||
log_cli_level = CRITICAL | ||
log_cli_format = %(message)s | ||
log_file_level = INFO | ||
log_file_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) | ||
log_file_date_format=%Y-%m-%d %H:%M:%S | ||
|
||
src_path = {tox_root}/src | ||
tests_path = {tox_root}/tests | ||
all_path = {[vars]src_path} {[vars]tests_path} | ||
|
||
[testenv] | ||
basepython = python3 | ||
setenv = | ||
PYTHONPATH={toxinidir}/src | ||
PYTHONBREAKPOINT=ipdb.set_trace | ||
passenv = HOME,KUBECONFIG | ||
|
||
[testenv:lint] | ||
deps = | ||
-rrequirements-test.txt | ||
commands = | ||
codespell {[vars]all_path} | ||
ruff {[vars]all_path} | ||
isort --check-only --diff {[vars]all_path} | ||
black --check --diff {[vars]all_path} | ||
set_env = | ||
PYTHONPATH = {tox_root}/lib:{[vars]src_path} | ||
PYTHONBREAKPOINT=pdb.set_trace | ||
PY_COLORS=1 | ||
pass_env = | ||
PYTHONPATH | ||
CHARM_BUILD_DIR | ||
MODEL_SETTINGS | ||
|
||
[testenv:format] | ||
description = Apply coding style standards to code | ||
deps = | ||
-rrequirements-test.txt | ||
black | ||
ruff | ||
commands = | ||
isort {[vars]all_path} | ||
black {[vars]all_path} | ||
ruff --fix {[vars]all_path} | ||
|
||
[testenv:lint] | ||
description = Check code against coding style standards | ||
deps = | ||
black | ||
ruff | ||
codespell | ||
commands = | ||
codespell {tox_root} | ||
ruff {[vars]all_path} | ||
black --check --diff {[vars]all_path} | ||
|
||
[testenv:unit] | ||
deps = | ||
-rrequirements-test.txt | ||
-r requirements-test.txt | ||
setenv = | ||
PYTHONPATH={toxinidir}:{toxinidir}/lib:{toxinidir}/src | ||
commands = | ||
pytest --cov=charm --cov-report=term-missing --asyncio-mode=auto --tb native -s {posargs:tests/unit} | ||
|
||
[testenv:integration] | ||
deps = | ||
-rrequirements-test.txt | ||
-r requirements-test.txt | ||
setenv = | ||
PYTHONPATH={toxinidir}:{toxinidir}/lib:{toxinidir}/src | ||
commands = | ||
pytest --log-cli-level=INFO --asyncio-mode=auto --tb native -s tests/integration {posargs} | ||
pytest --log-cli-level=INFO --asyncio-mode=auto --tb native -s tests/integration {posargs} {[vars]tests_path}/integration |