Skip to content

Commit

Permalink
Added ruff linter ignore for typer issue with Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
OCopping committed May 28, 2024
1 parent 2e3443d commit a9010c1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/edge_containers_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

import typer

import edge_containers_cli.globals as globals
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/edge_containers_cli/cmds/helm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tempfile
from pathlib import Path
from typing import Optional

import typer
from ruamel.yaml import YAML
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/edge_containers_cli/cmds/k8s_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import datetime
from io import StringIO
from pathlib import Path
from typing import Optional

import polars
import typer
Expand Down Expand Up @@ -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 ""
Expand Down
3 changes: 2 additions & 1 deletion src/edge_containers_cli/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
from pathlib import Path
from time import sleep
from typing import Optional

import typer

Expand Down Expand Up @@ -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
"""
Expand Down
3 changes: 2 additions & 1 deletion src/edge_containers_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit a9010c1

Please sign in to comment.