diff --git a/pyproject.toml b/pyproject.toml index 7331361..0c36cfd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ classifiers = [ python = "^3.9" boto3 = "^1.35" click = "^8.1" -graphlib_backport = {version = "^1.1", python = "<3.9"} pydantic = "^2.8" tomli = "^2.0" @@ -52,7 +51,7 @@ mkdocs = "^1.6" qldebugger = "qldebugger.cli:cli" [tool.ruff] -target-version = "py38" +target-version = "py39" line-length = 119 src = ["src", "tests"] diff --git a/src/qldebugger/actions/infra.py b/src/qldebugger/actions/infra.py index e435d4e..cbb9904 100644 --- a/src/qldebugger/actions/infra.py +++ b/src/qldebugger/actions/infra.py @@ -1,9 +1,9 @@ import json import logging -from typing import TYPE_CHECKING, Dict +from graphlib import TopologicalSorter +from typing import TYPE_CHECKING from botocore.exceptions import ClientError -from graphlib import TopologicalSorter from qldebugger.aws import get_account_id, get_client from qldebugger.config import get_config @@ -57,7 +57,7 @@ def create_queues() -> None: ).static_order() for queue_name in order: - attributes: Dict['QueueAttributeNameType', str] = {} + attributes: dict['QueueAttributeNameType', str] = {} if redrive_policy := queues.get(queue_name, ConfigQueue()).redrive_policy: logger.debug('Checking dead letter queue (%r) for %r...', redrive_policy.dead_letter_queue, queue_name) dead_letter_queue_attributes = sqs.get_queue_attributes( diff --git a/src/qldebugger/actions/message.py b/src/qldebugger/actions/message.py index f6ceda4..352c1aa 100644 --- a/src/qldebugger/actions/message.py +++ b/src/qldebugger/actions/message.py @@ -1,5 +1,6 @@ import logging -from typing import TYPE_CHECKING, Mapping +from collections.abc import Mapping +from typing import TYPE_CHECKING from qldebugger.aws import get_account_id, get_client diff --git a/src/qldebugger/cli.py b/src/qldebugger/cli.py index adfcbb0..40047e8 100644 --- a/src/qldebugger/cli.py +++ b/src/qldebugger/cli.py @@ -1,7 +1,8 @@ import json import logging +from collections.abc import Mapping from pathlib import Path -from typing import TYPE_CHECKING, Mapping +from typing import TYPE_CHECKING import click diff --git a/src/qldebugger/config/file_parser.py b/src/qldebugger/config/file_parser.py index d6fded8..fffea2e 100644 --- a/src/qldebugger/config/file_parser.py +++ b/src/qldebugger/config/file_parser.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Any, BinaryIO, Dict, List, NamedTuple, Optional, Tuple, Union +from typing import Any, BinaryIO, NamedTuple, Optional, Union import tomli from pydantic import BaseModel, Field, PositiveInt, field_validator @@ -41,7 +41,7 @@ class ConfigTopicSubscriber(BaseModel): class ConfigTopic(BaseModel): - subscribers: List[ConfigTopicSubscriber] = Field(default_factory=list) + subscribers: list[ConfigTopicSubscriber] = Field(default_factory=list) class ConfigQueueRedrivePolicy(BaseModel): @@ -60,11 +60,11 @@ class NameHandlerTuple(NamedTuple): class ConfigLambda(BaseModel): handler: NameHandlerTuple - environment: Dict[str, str] = Field(default_factory=dict) + environment: dict[str, str] = Field(default_factory=dict) @field_validator('handler', mode='before') @classmethod - def _split_handler(cls, v: Any) -> Tuple[str, str]: + def _split_handler(cls, v: Any) -> tuple[str, str]: if not isinstance(v, str): raise ValueError('should be a str') if '.' not in v: @@ -82,11 +82,11 @@ class ConfigEventSourceMapping(BaseModel): class Config(BaseModel): aws: ConfigAWS = Field(default_factory=ConfigAWS) - secrets: Dict[str, Union[ConfigSecretString, ConfigSecretBinary]] = Field(default_factory=dict) - topics: Dict[str, ConfigTopic] = Field(default_factory=dict) - queues: Dict[str, ConfigQueue] - lambdas: Dict[str, ConfigLambda] - event_source_mapping: Dict[str, ConfigEventSourceMapping] + secrets: dict[str, Union[ConfigSecretString, ConfigSecretBinary]] = Field(default_factory=dict) + topics: dict[str, ConfigTopic] = Field(default_factory=dict) + queues: dict[str, ConfigQueue] + lambdas: dict[str, ConfigLambda] + event_source_mapping: dict[str, ConfigEventSourceMapping] @classmethod def from_toml(cls, fp: BinaryIO, /) -> 'Config': diff --git a/tests/qldebugger/actions/test_infra.py b/tests/qldebugger/actions/test_infra.py index 80e5851..3f392a5 100644 --- a/tests/qldebugger/actions/test_infra.py +++ b/tests/qldebugger/actions/test_infra.py @@ -1,7 +1,6 @@ import json from collections import OrderedDict from random import randint -from typing import Dict from unittest.mock import Mock, call, patch from botocore.exceptions import ClientError @@ -249,7 +248,7 @@ def test_create_dead_letter_and_update_queue(self, mock_get_config: Mock, mock_g max_receive_count = randint(1, 10) host = randstr() - def get_queue_url(*, QueueName: str) -> Dict[str, str]: # noqa: N803 + def get_queue_url(*, QueueName: str) -> dict[str, str]: # noqa: N803 if QueueName != queue_name: raise ClientError({}, '') return {'QueueUrl': f'http://{host}/{QueueName}'} diff --git a/tests/qldebugger/actions/test_message.py b/tests/qldebugger/actions/test_message.py index 81d9c42..baf2c16 100644 --- a/tests/qldebugger/actions/test_message.py +++ b/tests/qldebugger/actions/test_message.py @@ -1,5 +1,6 @@ +from collections.abc import Mapping from random import randint -from typing import TYPE_CHECKING, Any, Mapping, cast +from typing import TYPE_CHECKING, Any, cast from unittest.mock import Mock, patch import pytest diff --git a/tests/qldebugger/config/test_file_parser.py b/tests/qldebugger/config/test_file_parser.py index 9a63876..39a3e99 100644 --- a/tests/qldebugger/config/test_file_parser.py +++ b/tests/qldebugger/config/test_file_parser.py @@ -1,6 +1,6 @@ from io import BytesIO from random import randint -from typing import Any, ClassVar, Dict +from typing import Any, ClassVar from unittest.mock import Mock, patch import pytest @@ -104,7 +104,7 @@ def test_tuple(self) -> None: class TestConfigLambda: - DEFAULT_ARGS: ClassVar[Dict[str, Any]] = { + DEFAULT_ARGS: ClassVar[dict[str, Any]] = { 'handler': f'{randstr()}.{randstr()}', }