diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 96fd726..88c7a6d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,31 +18,17 @@ jobs: lint-unit: name: Lint Unit - uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@main + uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@akd/provide-uv-support 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 - runs-on: ubuntu-24.04 - strategy: - matrix: - python-version: - - "3.8" - - "3.10" - - "3.12" - steps: - - uses: actions/checkout@v4 - - - uses: astral-sh/setup-uv@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install the project - run: uv sync --all-extras --dev - - - name: Run tests - run: - tox -e unit,lint + lint-unit-uv: + name: Lint and Unit Tests (with uv) + uses: charmed-kubernetes/workflows/.github/workflows/lint-unit.yaml@akd/provide-uv-support + with: + python: "['3.8', '3.10', '3.12']" + with-uv: true + needs: + - call-inclusive-naming-check diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 65e1721..0000000 --- a/mypy.ini +++ /dev/null @@ -1,11 +0,0 @@ -[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 - -# Ignore unsupported imports -[mypy-charms.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4080ffe --- /dev/null +++ b/pyproject.toml @@ -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" +] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 1c4dc17..4f3dede 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ tox isort black types-PyYAML -uv \ No newline at end of file +uv diff --git a/src/charm.py b/src/charm.py index 924affb..e8ba072 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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}'")) diff --git a/tox.ini b/tox.ini index 19dd6f2..80e23a0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] skipsdist=True envlist = lint, unit -requires = - pip >= 20.3 +; requires = +; pip >= 20.3 [vars] cov_path = {toxinidir}/htmlcov @@ -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 @@ -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