Skip to content

Commit

Permalink
centralize config to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Jan 13, 2025
1 parent f28beef commit 5fbdbdb
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
name: Lint Unit
uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@main
with:
python: "['3.8', '3.9', '3.10', '3.11']"
python: "['3.8', '3.10', '3.12']"
needs:
- call-inclusive-naming-check

test-with-uv:
name: continuous-integration
name: Lint and Unit Tests (with uv)
runs-on: ubuntu-24.04
strategy:
matrix:
Expand Down
11 changes: 0 additions & 11 deletions mypy.ini

This file was deleted.

82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[lint]
ignore = ["E501", "D107"]
extend-ignore = [
"D203",
"D204",
"D213",
"D215",
"D400",
"D404",
"D406",
"D407",
"D408",
"D409",
"D413",
]
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104"]}

[lint.mccabe]
max-complexity = 10



# Testing tools configuration
[tool.coverage.run]
branch = true

# Formatting tools configuration
[tool.black]
line-length = 99
target-version = ["py38"]

[tool.coverage.report]
show_missing = true


[tool.isort]
line_length=99
multi_line_output=3
include_trailing_comma = true
use_parentheses = true

[tool.mypy]
warn_unused_ignores = true
warn_unused_configs = true
warn_unreachable = true
disallow_untyped_defs = true
# Due to python 3.5 support we can't enforce variable type annotations
disable_error_code = "var-annotated"

[[tool.mypy.overrides]]
module = "charms.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "lightkube.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "ops.*"
ignore_missing_imports = true

[tool.pytest.ini_options]
minversion = "6.0"

# Linting tools configuration
[tool.ruff]
# line-length = 99
# select = ["E", "W", "F", "C", "N", "D", "I001"]
extend-exclude = ["__pycache__", "*.egg_info"]

[tool.codespell]
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.coverage"

[tool.pyright]
extraPaths = ["./lib"]

[project]
name = "ceph-csi"
dynamic = ["version"]
dependencies = [
"tox-uv"
]
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ tox
isort
black
types-PyYAML
uv
uv
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def check_kube_config(self) -> None:
def check_namespace(self) -> None:
self.unit.status = ops.MaintenanceStatus("Evaluating namespace")
try:
self._client.get(Namespace, name=self.stored.namespace) # type: ignore
self._client.get(Namespace, name=self.stored.namespace)
except ApiError as e:
if "not found" in str(e.status.message):
status.add(ops.BlockedStatus(f"Missing namespace '{self.stored.namespace}'"))
Expand Down
12 changes: 3 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
skipsdist=True
envlist = lint, unit
requires =
pip >= 20.3
; requires =
; pip >= 20.3

[vars]
cov_path = {toxinidir}/htmlcov
Expand All @@ -28,7 +28,7 @@ commands =
uvx ruff check {[vars]all_path}
uvx isort --check-only --diff {[vars]all_path}
uvx black -l 99 --check --diff {[vars]all_path}
uv run mypy --namespace-packages {[vars]src_path}
uvx mypy --namespace-packages {[vars]src_path}

[testenv:unit]
basepython = python3
Expand Down Expand Up @@ -65,12 +65,6 @@ commands =
python {toxinidir}/upstream/update.py {posargs}


[isort]
line_length=99
multi_line_output=3
include_trailing_comma=True
use_parentheses=True

[coverage:report]
exclude_lines =
pragma: no cover
Expand Down

0 comments on commit 5fbdbdb

Please sign in to comment.