From 1d4f0828b789870eec15ced45f87c510894ece9f Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Tue, 13 Feb 2024 12:29:48 +0200 Subject: [PATCH] Fix lints --- poetry.lock | 13 ++++++- pyproject.toml | 1 + .../junebug_message_api.py | 11 +++--- .../junebug_state_cache.py | 15 ++++---- .../junebug_message_api/messages.py | 16 ++++----- src/vumi2/async_helpers.py | 4 +-- src/vumi2/config.py | 13 +++---- src/vumi2/connectors.py | 8 ++--- src/vumi2/message_caches.py | 8 ++--- src/vumi2/messages.py | 24 ++++++------- src/vumi2/transports/httprpc/http_rpc.py | 7 ++-- src/vumi2/transports/smpp/client.py | 12 +++---- src/vumi2/transports/smpp/processors.py | 35 +++++++++---------- src/vumi2/transports/smpp/smpp.py | 5 ++- src/vumi2/transports/smpp/smpp_cache.py | 10 +++--- 15 files changed, 92 insertions(+), 90 deletions(-) diff --git a/poetry.lock b/poetry.lock index 90e8190..96fec2a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1509,6 +1509,17 @@ typing-extensions = ">=3.7.4" [package.extras] mypy = ["mypy (>=0.920)"] +[[package]] +name = "types-pyyaml" +version = "6.0.12.12" +description = "Typing stubs for PyYAML" +optional = false +python-versions = "*" +files = [ + {file = "types-PyYAML-6.0.12.12.tar.gz", hash = "sha256:334373d392fde0fdf95af5c3f1661885fa10c52167b14593eb856289e1855062"}, + {file = "types_PyYAML-6.0.12.12-py3-none-any.whl", hash = "sha256:c05bc6c158facb0676674b7f11fe3960db4f389718e19e62bd2b84d6205cfd24"}, +] + [[package]] name = "typing-extensions" version = "4.5.0" @@ -1644,4 +1655,4 @@ h11 = ">=0.9.0,<1" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "6e80e4144dd6efdb0193990922d1626411b48733842c4bf1d0647892b98a2023" +content-hash = "fa6f87ee27c6fac5dab4f304b0a234dc1201e94f50d1a42046d6bdda783dc83a" diff --git a/pyproject.toml b/pyproject.toml index ce84046..1ed27ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ ruff = "^0.0.261" Sphinx = "^6.1.3" sphinxcontrib-httpdomain = "^1.8.1" trio-typing = "^0.8.0" +types-pyyaml = "^6.0" [tool.poetry.group.lsp] optional = true diff --git a/src/vumi2/applications/junebug_message_api/junebug_message_api.py b/src/vumi2/applications/junebug_message_api/junebug_message_api.py index b245a51..74d71a5 100644 --- a/src/vumi2/applications/junebug_message_api/junebug_message_api.py +++ b/src/vumi2/applications/junebug_message_api/junebug_message_api.py @@ -1,7 +1,6 @@ import json from http import HTTPStatus from logging import getLogger -from typing import Optional, Union from attrs import define, field from httpx import AsyncClient @@ -54,12 +53,12 @@ class JunebugMessageApiConfig(BaseConfig): # The URL to POST inbound messages to. mo_message_url: str # Authorization token to use for inbound message HTTP requests. - mo_message_url_auth_token: Optional[str] = None + mo_message_url_auth_token: str | None = None # The URL to POST events with no associated message info to. - default_event_url: Optional[str] = None + default_event_url: str | None = None # Authorization token to use for events with no associates message info. - default_event_auth_token: Optional[str] = None + default_event_auth_token: str | None = None # Base URL path for outbound message HTTP requests. This has "/messages" # appended to it. For compatibility with existing Junebug API clients, set @@ -71,7 +70,7 @@ class JunebugMessageApiConfig(BaseConfig): transport_type: TransportType = TransportType.SMS # If None, all outbound messages must be replies or have a from address. - default_from_addr: Optional[str] = None + default_from_addr: str | None = None # If True, outbound messages with both `to` and `reply_to` set will be sent # as non-reply messages if the `reply_to` message can't be found. @@ -188,7 +187,7 @@ async def handle_event(self, event: Event) -> None: if cs.cancelled_caught: logger.error(LOG_EV_HTTP_TIMEOUT, {"timeout": timeout, "event": ev}) - async def http_send_message(self) -> tuple[Union[str, dict], int, dict[str, str]]: + async def http_send_message(self) -> tuple[str | dict, int, dict[str, str]]: _message_id = generate_message_id() try: # TODO: Log requests that timed out? diff --git a/src/vumi2/applications/junebug_message_api/junebug_state_cache.py b/src/vumi2/applications/junebug_message_api/junebug_state_cache.py index 6317c7d..bc9dbfb 100644 --- a/src/vumi2/applications/junebug_message_api/junebug_state_cache.py +++ b/src/vumi2/applications/junebug_message_api/junebug_state_cache.py @@ -1,5 +1,4 @@ from abc import ABC, abstractmethod -from typing import Optional import cattrs from attrs import define @@ -11,7 +10,7 @@ @define(frozen=True) class EventHttpInfo: url: str - auth_token: Optional[str] + auth_token: str | None class JunebugStateCache(ABC): # pragma: no cover @@ -20,12 +19,12 @@ async def store_event_http_info( self, message_id: str, url: str, - auth_token: Optional[str], + auth_token: str | None, ) -> None: ... @abstractmethod - async def fetch_event_http_info(self, message_id: str) -> Optional[EventHttpInfo]: + async def fetch_event_http_info(self, message_id: str) -> EventHttpInfo | None: ... @abstractmethod @@ -37,7 +36,7 @@ async def store_inbound(self, msg: Message) -> None: ... @abstractmethod - async def fetch_inbound(self, message_id: str) -> Optional[Message]: + async def fetch_inbound(self, message_id: str) -> Message | None: ... @abstractmethod @@ -62,7 +61,7 @@ async def store_event_http_info( self, message_id: str, url: str, - auth_token: Optional[str], + auth_token: str | None, ) -> None: """ Stores the mapping between one or many smpp message IDs and the vumi message ID @@ -70,7 +69,7 @@ async def store_event_http_info( if self.config.store_event_info: self._event_http_info[message_id] = EventHttpInfo(url, auth_token) - async def fetch_event_http_info(self, message_id: str) -> Optional[EventHttpInfo]: + async def fetch_event_http_info(self, message_id: str) -> EventHttpInfo | None: return self._event_http_info[message_id] async def delete_event_http_info(self, message_id: str) -> None: @@ -82,7 +81,7 @@ async def store_inbound(self, msg: Message) -> None: """ self._inbound[msg.message_id] = msg.serialise() - async def fetch_inbound(self, message_id: str) -> Optional[Message]: + async def fetch_inbound(self, message_id: str) -> Message | None: msg = self._inbound[message_id] return Message.deserialise(msg) if msg else None diff --git a/src/vumi2/applications/junebug_message_api/messages.py b/src/vumi2/applications/junebug_message_api/messages.py index 165fc2e..adf6fd4 100644 --- a/src/vumi2/applications/junebug_message_api/messages.py +++ b/src/vumi2/applications/junebug_message_api/messages.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any import cattrs from attrs import define, field @@ -128,12 +128,12 @@ class JunebugOutboundMessage: """ content: str - to: Optional[str] = None - from_addr: Optional[str] = None - group: Optional[str] = None - reply_to: Optional[str] = None - event_url: Optional[str] = None - event_auth_token: Optional[str] = None + to: str | None = None + from_addr: str | None = None + group: str | None = None + reply_to: str | None = None + event_url: str | None = None + event_auth_token: str | None = None priority: int = 1 channel_data: dict[str, Any] = field(factory=dict) @@ -143,7 +143,7 @@ def __attrs_post_init__(self): @classmethod def deserialise( - cls, data: dict[str, Any], default_from: Optional[str] = None + cls, data: dict[str, Any], default_from: str | None = None ) -> "JunebugOutboundMessage": if data.get("from") is None: data["from"] = default_from diff --git a/src/vumi2/async_helpers.py b/src/vumi2/async_helpers.py index c7b3383..b442ff3 100644 --- a/src/vumi2/async_helpers.py +++ b/src/vumi2/async_helpers.py @@ -1,11 +1,11 @@ from collections.abc import Awaitable from inspect import isawaitable -from typing import TypeVar, Union, cast +from typing import TypeVar, cast _RETURN = TypeVar("_RETURN") -async def maybe_awaitable(value: Union[_RETURN, Awaitable[_RETURN]]) -> _RETURN: +async def maybe_awaitable(value: _RETURN | Awaitable[_RETURN]) -> _RETURN: if isawaitable(value): # cast because isawaitable doesn't properly narrow the type return await cast(Awaitable[_RETURN], value) diff --git a/src/vumi2/config.py b/src/vumi2/config.py index a2719db..7f24ba8 100644 --- a/src/vumi2/config.py +++ b/src/vumi2/config.py @@ -1,15 +1,12 @@ import os from argparse import Namespace -from collections.abc import Iterable +from collections.abc import Callable, Iterable from pathlib import Path from typing import ( Any, - Callable, Generic, - Optional, Protocol, TypeVar, - Union, get_type_hints, ) @@ -27,7 +24,7 @@ class Configurable(Protocol, Generic[CT]): config: CT -def get_config_class(cls: Union[Configurable[CT], type[Configurable[CT]]]) -> type[CT]: +def get_config_class(cls: Configurable[CT] | type[Configurable[CT]]) -> type[CT]: return get_type_hints(cls)["config"] @@ -37,7 +34,7 @@ def structure(config: dict, cls: type[CT]) -> CT: def structure_config( config: dict, - obj: Union[Configurable[CT], type[Configurable[CT]]], + obj: Configurable[CT] | type[Configurable[CT]], ) -> CT: return structure(config, get_config_class(obj)) @@ -56,8 +53,8 @@ class BaseConfig: amqp: AmqpConfig = Factory(AmqpConfig) amqp_url: str = "" worker_concurrency: int = 20 - sentry_dsn: Optional[str] = None - http_bind: Optional[str] = None + sentry_dsn: str | None = None + http_bind: str | None = None log_level: str = "INFO" diff --git a/src/vumi2/connectors.py b/src/vumi2/connectors.py index edfc5ca..08402a1 100644 --- a/src/vumi2/connectors.py +++ b/src/vumi2/connectors.py @@ -1,7 +1,7 @@ import json -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable from logging import getLogger -from typing import Callable, Optional, overload +from typing import overload import trio from async_amqp import AmqpProtocol # type: ignore @@ -16,8 +16,8 @@ logger = getLogger(__name__) -MessageCallbackType = Callable[[Message], Optional[Awaitable[None]]] -EventCallbackType = Callable[[Event], Optional[Awaitable[None]]] +MessageCallbackType = Callable[[Message], Awaitable[None] | None] +EventCallbackType = Callable[[Event], Awaitable[None] | None] _AmqpChType = tuple[Channel, bytes, Envelope, Properties] diff --git a/src/vumi2/message_caches.py b/src/vumi2/message_caches.py index 7f736f4..24cbffb 100644 --- a/src/vumi2/message_caches.py +++ b/src/vumi2/message_caches.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from collections.abc import Iterator, MutableMapping -from typing import Generic, Optional, TypeVar +from typing import Generic, TypeVar from attrs import define from cattrs import structure @@ -34,7 +34,7 @@ def __setitem__(self, key: str, value: T) -> None: self._remove_expired() self.data[key] = (current_time(), value) - def __getitem__(self, key: str) -> Optional[T]: + def __getitem__(self, key: str) -> T | None: self._remove_expired() if key not in self.data: return None @@ -63,7 +63,7 @@ async def store_outbound(self, outbound: Message) -> None: ... @abstractmethod - async def fetch_outbound(self, message_id: str) -> Optional[Message]: + async def fetch_outbound(self, message_id: str) -> Message | None: ... @@ -81,5 +81,5 @@ def __init__(self, config: dict) -> None: async def store_outbound(self, outbound: Message) -> None: self._outbounds[outbound.message_id] = outbound - async def fetch_outbound(self, message_id: str) -> Optional[Message]: + async def fetch_outbound(self, message_id: str) -> Message | None: return self._outbounds.get(message_id) diff --git a/src/vumi2/messages.py b/src/vumi2/messages.py index 868fd5e..84da6ec 100644 --- a/src/vumi2/messages.py +++ b/src/vumi2/messages.py @@ -1,6 +1,6 @@ from datetime import datetime from enum import Enum -from typing import Any, Optional, Union +from typing import Any, Union from uuid import uuid4 import cattrs @@ -80,14 +80,14 @@ class Message: routing_metadata: dict = Factory(dict) helper_metadata: dict = Factory(dict) message_id: str = Factory(generate_message_id) - in_reply_to: Optional[str] = None - provider: Optional[str] = None + in_reply_to: str | None = None + provider: str | None = None session_event: Session = Session.NONE - content: Optional[str] = None + content: str | None = None transport_metadata: dict = Factory(dict) - group: Optional[str] = None - to_addr_type: Optional[AddressType] = None - from_addr_type: Optional[AddressType] = None + group: str | None = None + to_addr_type: AddressType | None = None + from_addr_type: AddressType | None = None def serialise(self) -> dict[str, Any]: return cattrs.unstructure(self) @@ -97,7 +97,7 @@ def deserialise(cls: "type[Message]", data: dict[str, Any]) -> "Message": return cattrs.structure(data, cls) def reply( - self, content: Optional[str] = None, session_event=Session.RESUME, **kwargs + self, content: str | None = None, session_event=Session.RESUME, **kwargs ) -> "Message": for f in [ "to_addr", @@ -138,11 +138,11 @@ class Event: timestamp: datetime = Factory(datetime.utcnow) routing_metadata: dict = Factory(dict) helper_metadata: dict = Factory(dict) - transport_metadata: Optional[dict] = Factory(dict) + transport_metadata: dict | None = Factory(dict) event_id: str = Factory(generate_message_id) - sent_message_id: Optional[str] = None - nack_reason: Optional[str] = None - delivery_status: Optional[DeliveryStatus] = None + sent_message_id: str | None = None + nack_reason: str | None = None + delivery_status: DeliveryStatus | None = None @event_type.validator def _check_event_type(self, _, value: EventType) -> None: diff --git a/src/vumi2/transports/httprpc/http_rpc.py b/src/vumi2/transports/httprpc/http_rpc.py index 604e06e..b5c6e9f 100644 --- a/src/vumi2/transports/httprpc/http_rpc.py +++ b/src/vumi2/transports/httprpc/http_rpc.py @@ -1,5 +1,4 @@ from logging import getLogger -from typing import Union from attrs import Factory, define from quart import request @@ -32,7 +31,7 @@ class Request: @define class Response: - data: Union[str, dict] + data: str | dict code: int headers: dict[str, str] @@ -49,7 +48,7 @@ async def setup(self) -> None: self.http.app.add_url_rule(self.config.web_path, view_func=self.inbound_request) await self.start_consuming() - async def inbound_request(self) -> tuple[Union[str, dict], int, dict[str, str]]: + async def inbound_request(self) -> tuple[str | dict, int, dict[str, str]]: message_id = generate_message_id() try: with move_on_after(self.config.request_timeout): @@ -135,7 +134,7 @@ async def handle_outbound_message(self, message: Message) -> None: await self.publish_ack(message.message_id) def finish_request( - self, request_id: str, data: Union[str, dict], code=200, headers=None + self, request_id: str, data: str | dict, code=200, headers=None ) -> None: headers = {} if headers is None else headers logger.debug( diff --git a/src/vumi2/transports/smpp/client.py b/src/vumi2/transports/smpp/client.py index d73956d..8e2c788 100644 --- a/src/vumi2/transports/smpp/client.py +++ b/src/vumi2/transports/smpp/client.py @@ -1,6 +1,6 @@ from io import BytesIO from logging import getLogger -from typing import TYPE_CHECKING, Optional, Union, cast +from typing import TYPE_CHECKING, cast from smpp.pdu.constants import ( # type: ignore command_status_name_map, @@ -176,7 +176,7 @@ async def handle_pdu(self, pdu: PDU) -> None: logger.warning("Unknown PDU type, ignoring %s", pdu) @staticmethod - def extract_pdu(data: bytearray) -> Optional[bytearray]: + def extract_pdu(data: bytearray) -> bytearray | None: """ Used for extracting PDUs from the buffer @@ -196,11 +196,11 @@ async def bind( self, system_id: str, password: str, - system_type: Optional[str] = None, + system_type: str | None = None, interface_version: int = 34, addr_ton: AddrTon = AddrTon.UNKNOWN, addr_npi: AddrNpi = AddrNpi.UNKNOWN, - address_range: Optional[str] = None, + address_range: str | None = None, ) -> PDU: """ Sends a bind request to the server, and waits for a successful bind response @@ -223,8 +223,8 @@ async def bind( return bind_response async def send_pdu( - self, pdu: Union[PDURequest, PDUResponse], check_response: bool = True - ) -> Optional[PDU]: + self, pdu: PDURequest | PDUResponse, check_response: bool = True + ) -> PDU | None: """ Sends the PDU, waits for, and returns the response PDU """ diff --git a/src/vumi2/transports/smpp/processors.py b/src/vumi2/transports/smpp/processors.py index aa92d6b..4138b44 100644 --- a/src/vumi2/transports/smpp/processors.py +++ b/src/vumi2/transports/smpp/processors.py @@ -1,7 +1,8 @@ import re +from collections.abc import Callable from enum import Enum from logging import getLogger -from typing import Callable, Optional, TypeVar, Union +from typing import TypeVar from attrs import Factory, define, field from smpp.pdu.operations import PDU, DeliverSM, SubmitSM # type: ignore @@ -30,8 +31,8 @@ ET = TypeVar("ET", bound=Enum) -def convert_enum(enum: type[ET]) -> Callable[[Union[int, str, ET]], ET]: - def _convert_enum(value: Union[int, str, ET]) -> ET: +def convert_enum(enum: type[ET]) -> Callable[[int | str | ET], ET]: + def _convert_enum(value: int | str | ET) -> ET: if isinstance(value, int): raise TypeError("Enums must be specified by name") if isinstance(value, str): @@ -41,10 +42,10 @@ def _convert_enum(value: Union[int, str, ET]) -> ET: return _convert_enum -def conv_enum_list(enum: type[ET]) -> Callable[[list[Union[int, str, ET]]], list[ET]]: +def conv_enum_list(enum: type[ET]) -> Callable[[list[int | str | ET]], list[ET]]: ce = convert_enum(enum) - def _conv_enum_list(values: list[Union[int, str, ET]]) -> list[ET]: + def _conv_enum_list(values: list[int | str | ET]) -> list[ET]: return [ce(val) for val in values] return _conv_enum_list @@ -106,7 +107,7 @@ class SubmitShortMessageProcessorConfig: default=DataCodingDefault.SMSC_DEFAULT_ALPHABET, ) multipart_handling: MultipartHandling = MultipartHandling.short_message - service_type: Optional[str] = None + service_type: str | None = None source_addr_ton: AddrTon = enum_field(AddrTon, default=AddrTon.UNKNOWN) source_addr_npi: AddrNpi = enum_field(AddrNpi, default=AddrNpi.UNKNOWN) dest_addr_ton: AddrTon = enum_field(AddrTon, default=AddrTon.UNKNOWN) @@ -285,7 +286,7 @@ def __init__(self, config: dict) -> None: async def handle_deliver_sm( # type: ignore self, pdu: DeliverSM, - ) -> tuple[bool, Optional[Event]]: + ) -> tuple[bool, Event | None]: ... @@ -336,7 +337,7 @@ def __init__(self, config: dict, smpp_cache: BaseSmppCache) -> None: async def _handle_deliver_sm_optional_params( self, pdu: DeliverSM - ) -> tuple[bool, Optional[Event]]: + ) -> tuple[bool, Event | None]: """ Check if this is a delivery report using the optional PDU params. @@ -352,7 +353,7 @@ async def _handle_deliver_sm_optional_params( async def _handle_deliver_sm_esm_class( self, pdu: DeliverSM - ) -> tuple[bool, Optional[Event]]: + ) -> tuple[bool, Event | None]: """ Check if this is a delivery report by looking at the esm_class. @@ -381,7 +382,7 @@ async def _handle_deliver_sm_esm_class( async def _handle_deliver_sm_body( self, pdu: DeliverSM - ) -> tuple[bool, Optional[Event]]: + ) -> tuple[bool, Event | None]: """ Try to decode the body as a delivery report, even if the esm_class doesn't say it's a delivery report @@ -396,7 +397,7 @@ async def _handle_deliver_sm_body( async def _create_event( self, smpp_message_id: str, smpp_status: str - ) -> Optional[Event]: + ) -> Event | None: status = DeliveryStatus(self.config.status_mapping.get(smpp_status, "pending")) vumi_message_id = await self.smpp_cache.get_smpp_message_id(smpp_message_id) if not vumi_message_id: @@ -418,7 +419,7 @@ async def _create_event( transport_metadata={"smpp_delivery_status": smpp_status}, ) - async def handle_deliver_sm(self, pdu: DeliverSM) -> tuple[bool, Optional[Event]]: + async def handle_deliver_sm(self, pdu: DeliverSM) -> tuple[bool, Event | None]: """ Try to handle the pdu as a delivery report. Returns an equivalent Event if handled, or None if not. @@ -438,7 +439,7 @@ class ShortMessageProcesserBase: # pragma: no cover def __init__(self, config: dict, smpp_cache: BaseSmppCache) -> None: ... - async def handle_deliver_sm(self, pdu: DeliverSM) -> Optional[Message]: + async def handle_deliver_sm(self, pdu: DeliverSM) -> Message | None: ... @@ -484,9 +485,7 @@ def _handle_short_message(self, pdu: DeliverSM) -> Message: content=self._get_text(pdu), ) - def _extract_multipart( - self, pdu: DeliverSM - ) -> Optional[tuple[int, int, int, bytes]]: + def _extract_multipart(self, pdu: DeliverSM) -> tuple[int, int, int, bytes] | None: """ Tries to extract the multipart data from the PDU, using optional params, or UDH CSM or CSM16. @@ -531,7 +530,7 @@ def _extract_multipart( async def _handle_multipart_message( self, pdu: DeliverSM - ) -> tuple[bool, Optional[Message]]: + ) -> tuple[bool, Message | None]: """ Tries to handle the message as a multipart message. @@ -559,7 +558,7 @@ async def _handle_multipart_message( content=full_message, ) - async def handle_deliver_sm(self, pdu: DeliverSM) -> Optional[Message]: + async def handle_deliver_sm(self, pdu: DeliverSM) -> Message | None: """ Processes the DeliverSM pdu, and returns a Message if one was decoded, else returns None. diff --git a/src/vumi2/transports/smpp/smpp.py b/src/vumi2/transports/smpp/smpp.py index 0c37b87..dcff610 100644 --- a/src/vumi2/transports/smpp/smpp.py +++ b/src/vumi2/transports/smpp/smpp.py @@ -1,5 +1,4 @@ from logging import getLogger -from typing import Optional from async_amqp import AmqpProtocol # type: ignore from attrs import Factory, define @@ -21,9 +20,9 @@ class SmppTransceiverTransportConfig(BaseConfig): port: int = 2775 system_id: str = "smppclient1" password: str = "password" - system_type: Optional[str] = None + system_type: str | None = None interface_version: int = 34 - address_range: Optional[str] = None + address_range: str | None = None smpp_enquire_link_interval: int = 55 sequencer_class: str = "vumi2.transports.smpp.sequencers.InMemorySequencer" sequencer_config: dict = Factory(dict) diff --git a/src/vumi2/transports/smpp/smpp_cache.py b/src/vumi2/transports/smpp/smpp_cache.py index 563bfc9..13eb39a 100644 --- a/src/vumi2/transports/smpp/smpp_cache.py +++ b/src/vumi2/transports/smpp/smpp_cache.py @@ -1,5 +1,3 @@ -from typing import Optional - import cattrs from attrs import define @@ -12,7 +10,7 @@ def __init__(self, config: dict) -> None: async def store_multipart( self, ref_num: int, tot_num: int, part_num: int, content: str - ) -> Optional[str]: + ) -> str | None: ... async def store_smpp_message_id( @@ -23,7 +21,7 @@ async def store_smpp_message_id( async def delete_smpp_message_id(self, smpp_message_id: str) -> None: ... - async def get_smpp_message_id(self, smpp_message_id: str) -> Optional[str]: + async def get_smpp_message_id(self, smpp_message_id: str) -> str | None: ... @@ -40,7 +38,7 @@ def __init__(self, config: dict) -> None: async def store_multipart( self, ref_num: int, tot_num: int, part_num: int, content: str - ) -> Optional[str]: + ) -> str | None: """ Stores the one part of a multipart message in the cache. If this results in all the parts being stored in the cache, removes them from the cache and returns @@ -68,7 +66,7 @@ async def delete_smpp_message_id(self, smpp_message_id: str) -> None: """ self._smpp_msg_id.pop(smpp_message_id, None) - async def get_smpp_message_id(self, smpp_message_id: str) -> Optional[str]: + async def get_smpp_message_id(self, smpp_message_id: str) -> str | None: """ Returns the vumi message ID for the given smpp message id """