diff --git a/.github/pages/make_switcher.py b/.github/pages/make_switcher.py index 6d90f490..2b81e769 100755 --- a/.github/pages/make_switcher.py +++ b/.github/pages/make_switcher.py @@ -3,6 +3,7 @@ from argparse import ArgumentParser from pathlib import Path from subprocess import CalledProcessError, check_output +from typing import Optional def report_output(stdout: bytes, label: str) -> list[str]: @@ -23,7 +24,7 @@ def get_sorted_tags_list() -> list[str]: return report_output(stdout, "Tags list") -def get_versions(ref: str, add: str | None) -> list[str]: +def get_versions(ref: str, add: Optional[str]) -> list[str]: """Generate the file containing the list of all GitHub Pages builds.""" # Get the directories (i.e. builds) from the GitHub Pages branch try: diff --git a/pyproject.toml b/pyproject.toml index ba2dc17f..5cebfce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,9 +109,10 @@ commands = src = ["src", "tests"] line-length = 88 lint.ignore = [ - "C408", # Unnecessary collection call - e.g. list(...) instead of [...] - "E501", # Line too long, should be fixed by black. - "B008", # Do not perform function calls in argument defaults. + "C408", # Unnecessary collection call - e.g. list(...) instead of [...] + "E501", # Line too long, should be fixed by black. + "B008", # Do not perform function calls in argument defaults. + "UP007", # Do not complain about Optional[] (TODO: remove once typer is patched) ] lint.select = [ "B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b diff --git a/src/edge_containers_cli/__main__.py b/src/edge_containers_cli/__main__.py index 1f704347..0a8fdccc 100644 --- a/src/edge_containers_cli/__main__.py +++ b/src/edge_containers_cli/__main__.py @@ -1,3 +1,5 @@ +from typing import Optional + import typer import edge_containers_cli.globals as globals @@ -18,7 +20,7 @@ def version_callback(value: bool): @cli.callback() def main( ctx: typer.Context, - version: bool | None = typer.Option( + version: Optional[bool] = typer.Option( None, "--version", callback=version_callback, diff --git a/src/edge_containers_cli/cmds/helm.py b/src/edge_containers_cli/cmds/helm.py index 2546cf93..79759254 100644 --- a/src/edge_containers_cli/cmds/helm.py +++ b/src/edge_containers_cli/cmds/helm.py @@ -1,5 +1,6 @@ import tempfile from pathlib import Path +from typing import Optional import typer from ruamel.yaml import YAML @@ -25,9 +26,9 @@ def __init__( namespace: str, service_name: str, args: str = "", - version: str | None = None, + version: Optional[str] = None, template: bool = False, - repo: str | None = None, + repo: Optional[str] = None, ): """ Create a helm chart from a local or a remote repo diff --git a/src/edge_containers_cli/cmds/k8s_commands.py b/src/edge_containers_cli/cmds/k8s_commands.py index b3e166e4..37035274 100644 --- a/src/edge_containers_cli/cmds/k8s_commands.py +++ b/src/edge_containers_cli/cmds/k8s_commands.py @@ -7,6 +7,7 @@ from datetime import datetime from io import StringIO from pathlib import Path +from typing import Optional import polars import typer @@ -124,7 +125,7 @@ def exec(self, service_name): def logs( self, service_name: str, prev: bool, follow: bool, stdout: bool = False - ) -> str | bool | None: + ) -> Optional[str | bool]: fullname = check_service(service_name, self.namespace) previous = "-p" if prev else "" fol = "-f" if follow else "" diff --git a/src/edge_containers_cli/docker.py b/src/edge_containers_cli/docker.py index e036d5d2..7a0000ff 100644 --- a/src/edge_containers_cli/docker.py +++ b/src/edge_containers_cli/docker.py @@ -5,6 +5,7 @@ import re from pathlib import Path from time import sleep +from typing import Optional import typer @@ -110,7 +111,7 @@ def logs( previous: bool = False, follow: bool = False, stdout: bool = False, - ) -> str | bool | None: + ) -> Optional[str | bool]: """ show logs from a container """ diff --git a/src/edge_containers_cli/utils.py b/src/edge_containers_cli/utils.py index af7d2e5a..35878eb7 100644 --- a/src/edge_containers_cli/utils.py +++ b/src/edge_containers_cli/utils.py @@ -8,6 +8,7 @@ import shutil from datetime import datetime from pathlib import Path +from typing import Optional import typer from ruamel.yaml import YAML @@ -16,7 +17,7 @@ from edge_containers_cli.logging import log -def get_instance_image_name(svc_instance: Path, tag: str | None = None) -> str: +def get_instance_image_name(svc_instance: Path, tag: Optional[str] = None) -> str: svc_instance = svc_instance.resolve() values = svc_instance / "values.yaml" if not values.exists():