diff --git a/async_firebase/base.py b/async_firebase/base.py index 2dbd58a..8db2e8d 100644 --- a/async_firebase/base.py +++ b/async_firebase/base.py @@ -11,7 +11,6 @@ from email.mime.nonmultipart import MIMENonMultipart from importlib.metadata import version from pathlib import PurePath -from typing import Any, Coroutine from urllib.parse import urlencode import httpx @@ -20,11 +19,11 @@ from async_firebase._config import DEFAULT_REQUEST_LIMITS, DEFAULT_REQUEST_TIMEOUT, RequestLimits, RequestTimeout from async_firebase.messages import FCMBatchResponse, FCMResponse, TopicManagementResponse from async_firebase.utils import ( - FCMBatchResponseHandler, + FCMBatchResponseHandler, FCMResponseHandler, TopicManagementResponseHandler, - join_url, - serialize_mime_message + join_url, + serialize_mime_message, ) @@ -172,7 +171,7 @@ async def prepare_headers(self) -> t.Dict[str, str]: "X-GOOG-API-FORMAT-VERSION": "2", "X-FIREBASE-CLIENT": "async-firebase/{0}".format(version("async-firebase")), } - + async def _send_request( self, url: str, @@ -227,12 +226,8 @@ async def send_request( :return: HTTP response """ url = join_url(self.BASE_URL, uri) - return await self._send_request( # type: ignore - url=url, - response_handler=response_handler, - json_payload=json_payload, - headers=headers, - content=content + return await self._send_request( # type: ignore + url=url, response_handler=response_handler, json_payload=json_payload, headers=headers, content=content ) async def send_iid_request( @@ -256,10 +251,6 @@ async def send_iid_request( url = join_url(self.IID_URL, uri) headers = headers or await self.prepare_headers() headers.update(self.IID_HEADERS) - return await self._send_request( # type: ignore - url=url, - response_handler=response_handler, - json_payload=json_payload, - headers=headers, - content=content + return await self._send_request( # type: ignore + url=url, response_handler=response_handler, json_payload=json_payload, headers=headers, content=content ) diff --git a/async_firebase/client.py b/async_firebase/client.py index 06d9b26..8e36ea3 100644 --- a/async_firebase/client.py +++ b/async_firebase/client.py @@ -551,10 +551,7 @@ async def send_each_for_multicast( return await self.send_each(messages, dry_run=dry_run) async def _make_topic_management_request( - self, - device_tokens: t.List[str], - topic_name: str, - action: str + self, device_tokens: t.List[str], topic_name: str, action: str ) -> TopicManagementResponse: payload = { "to": f"/topics/{topic_name}", @@ -567,11 +564,7 @@ async def _make_topic_management_request( ) return response - async def subscribe_devices_to_topic( - self, - device_tokens: t.List[str], - topic_name: str - ) -> TopicManagementResponse: + async def subscribe_devices_to_topic(self, device_tokens: t.List[str], topic_name: str) -> TopicManagementResponse: """ Subscribes devices to the topic. @@ -580,15 +573,11 @@ async def subscribe_devices_to_topic( :returns: Instance of messages.TopicManagementResponse. """ return await self._make_topic_management_request( - device_tokens=device_tokens, - topic_name=topic_name, - action=self.TOPIC_ADD_ACTION + device_tokens=device_tokens, topic_name=topic_name, action=self.TOPIC_ADD_ACTION ) async def unsubscribe_devices_from_topic( - self, - device_tokens: t.List[str], - topic_name: str + self, device_tokens: t.List[str], topic_name: str ) -> TopicManagementResponse: """ Unsubscribes devices from the topic. @@ -598,7 +587,5 @@ async def unsubscribe_devices_from_topic( :returns: Instance of messages.TopicManagementResponse. """ return await self._make_topic_management_request( - device_tokens=device_tokens, - topic_name=topic_name, - action=self.TOPIC_REMOVE_ACTION + device_tokens=device_tokens, topic_name=topic_name, action=self.TOPIC_REMOVE_ACTION ) diff --git a/async_firebase/messages.py b/async_firebase/messages.py index 8881e85..0be8ab2 100644 --- a/async_firebase/messages.py +++ b/async_firebase/messages.py @@ -289,6 +289,7 @@ class FcmOptions: Arguments: analytics_label: Label associated with the message's analytics data. """ + analytics_label: str @@ -432,9 +433,7 @@ def reason(self): class TopicManagementResponse: """The response received from a topic management operation.""" - def __init__( - self, resp: t.Optional[httpx.Response] = None, exception: t.Optional[AsyncFirebaseError] = None - ): + def __init__(self, resp: t.Optional[httpx.Response] = None, exception: t.Optional[AsyncFirebaseError] = None): self.exception = exception self._success_count = 0 self._failure_count = 0 diff --git a/async_firebase/utils.py b/async_firebase/utils.py index 59fb699..e15f783 100644 --- a/async_firebase/utils.py +++ b/async_firebase/utils.py @@ -24,11 +24,7 @@ UnknownError, UnregisteredError, ) -from async_firebase.messages import ( - FCMBatchResponse, - FCMResponse, - TopicManagementResponse, -) +from async_firebase.messages import FCMBatchResponse, FCMResponse, TopicManagementResponse def join_url(