Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoklosowski committed Oct 23, 2024
1 parent 67bbd68 commit ac95b27
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/qldebugger/actions/infra.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion src/qldebugger/actions/message.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/qldebugger/cli.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
18 changes: 9 additions & 9 deletions src/qldebugger/config/file_parser.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand All @@ -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':
Expand Down
3 changes: 1 addition & 2 deletions tests/qldebugger/actions/test_infra.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}'}
Expand Down
3 changes: 2 additions & 1 deletion tests/qldebugger/actions/test_message.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/qldebugger/config/test_file_parser.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()}',
}

Expand Down

0 comments on commit ac95b27

Please sign in to comment.