typer uses a syntax that disagrees with B008, added lint bypass for this case

pull/168/head
Andrew Mirsky 2025-05-19 13:15:22 -04:00
rodzic 582f8b16c7
commit bb3ec6e683
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A98E67635CDF2C39
4 zmienionych plików z 7 dodań i 10 usunięć

Wyświetl plik

@ -3,10 +3,8 @@ from collections import deque # pylint: disable=C0412
from typing import SupportsIndex, SupportsInt # pylint: disable=C0412 from typing import SupportsIndex, SupportsInt # pylint: disable=C0412
try: try:
from collections import deque
from collections.abc import Buffer from collections.abc import Buffer
except ImportError: except ImportError:
from collections import deque
from typing import Protocol, runtime_checkable from typing import Protocol, runtime_checkable
@runtime_checkable @runtime_checkable

Wyświetl plik

@ -18,7 +18,6 @@ from pathlib import Path
import typer import typer
import amqtt
from amqtt import __version__ as amqtt_version from amqtt import __version__ as amqtt_version
from amqtt.broker import Broker from amqtt.broker import Broker
from amqtt.utils import read_yaml_config from amqtt.utils import read_yaml_config
@ -64,7 +63,7 @@ def broker_main(
help="Show version and exit", help="Show version and exit",
), ),
) -> None: ) -> None:
"""Run the MQTT broker."""
formatter = "[%(asctime)s] :: %(levelname)s - %(message)s" formatter = "[%(asctime)s] :: %(levelname)s - %(message)s"
level = logging.DEBUG if debug else logging.INFO level = logging.DEBUG if debug else logging.INFO

Wyświetl plik

@ -1,13 +1,13 @@
import asyncio import asyncio
import contextlib import contextlib
from dataclasses import dataclass
import json import json
import logging import logging
import os import os
from dataclasses import dataclass
from pathlib import Path from pathlib import Path
import socket import socket
import sys import sys
from typing import Any, List from typing import Any
import typer import typer
@ -43,7 +43,7 @@ class CAInfo:
async def do_sub(client: MQTTClient, async def do_sub(client: MQTTClient,
url: str, url: str,
topics: List[str], topics: list[str],
ca_info: CAInfo, ca_info: CAInfo,
max_count: int | None = None, max_count: int | None = None,
clean_session: bool = False, clean_session: bool = False,
@ -91,6 +91,7 @@ async def do_sub(client: MQTTClient,
def main() -> None: def main() -> None:
"""Entry point for the amqtt subscriber."""
typer.run(subscribe_main) typer.run(subscribe_main)
@ -106,7 +107,7 @@ def subscribe_main( # pylint: disable=R0914,R0917 # noqa : PLR0913
client_id: str | None = typer.Option(None, "-i", help="Id to use as client ID"), client_id: str | None = typer.Option(None, "-i", help="Id to use as client ID"),
max_count: int | None = typer.Option(None, "-n", help="Number of messages to read before ending"), max_count: int | None = typer.Option(None, "-n", help="Number of messages to read before ending"),
qos: int = typer.Option(0, "--qos", "-q", help="Quality of service (0, 1, or 2)"), qos: int = typer.Option(0, "--qos", "-q", help="Quality of service (0, 1, or 2)"),
topics: List[str] = typer.Option(..., "-t", help="Topic filter to subscribe"), topics: list[str] = typer.Option(..., "-t", help="Topic filter to subscribe"), # noqa: B008
keep_alive: int | None = typer.Option(None, "-k", help="Keep alive timeout in seconds"), keep_alive: int | None = typer.Option(None, "-k", help="Keep alive timeout in seconds"),
clean_session: bool = typer.Option(False, help="Clean session on connect (defaults to False)"), clean_session: bool = typer.Option(False, help="Clean session on connect (defaults to False)"),
ca_file: str | None = typer.Option(None, "--ca-file", help="CA file"), ca_file: str | None = typer.Option(None, "--ca-file", help="CA file"),
@ -127,7 +128,6 @@ def subscribe_main( # pylint: disable=R0914,R0917 # noqa : PLR0913
), ),
) -> None: ) -> None:
"""Run the MQTT subscriber.""" """Run the MQTT subscriber."""
formatter = "[%(asctime)s] :: %(levelname)s - %(message)s" formatter = "[%(asctime)s] :: %(levelname)s - %(message)s"
level = logging.DEBUG if debug else logging.INFO level = logging.DEBUG if debug else logging.INFO
logging.basicConfig(level=level, format=formatter) logging.basicConfig(level=level, format=formatter)

Wyświetl plik

@ -124,7 +124,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"tests/**" = ["ALL"] "tests/**" = ["ALL"]
"amqtt/scripts/pub_script.py" = ["FBT003"] "amqtt/scripts/*_script.py" = ["FBT003"]
[tool.ruff.lint.flake8-pytest-style] [tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false fixture-parentheses = false