From d82e72d139ac30a8b4bd2b5fd459b4f9deb11017 Mon Sep 17 00:00:00 2001 From: troyraen Date: Sun, 14 Jan 2024 04:58:31 -0800 Subject: [PATCH] fix type hints --- pittgoogle/alert.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pittgoogle/alert.py b/pittgoogle/alert.py index 03dd017..b6c2908 100644 --- a/pittgoogle/alert.py +++ b/pittgoogle/alert.py @@ -26,7 +26,7 @@ import logging from datetime import datetime from pathlib import Path -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Dict, Optional, Union import fastavro from attrs import define, field @@ -77,10 +77,10 @@ class Alert: Union["google.cloud.pubsub_v1.types.PubsubMessage", types_.PubsubMessageLike] ] = field(default=None) """Incoming Pub/Sub message object.""" - _attributes: Optional[Union[dict, "google._upb._message.ScalarMapContainer"]] = field( + _attributes: Optional[Union[Dict, "google._upb._message.ScalarMapContainer"]] = field( default=None ) - _dict: Optional[dict] = field(default=None) + _dict: Optional[Dict] = field(default=None) _dataframe: Optional["pd.DataFrame"] = field(default=None) schema_name: Optional[str] = field(default=None) _schema: Optional[types_.Schema] = field(default=None, init=False) @@ -88,7 +88,7 @@ class Alert: # ---- class methods ---- # @classmethod - def from_cloud_run(cls, envelope: dict, schema_name: Optional[str] = None) -> "Alert": + def from_cloud_run(cls, envelope: Dict, schema_name: Optional[str] = None) -> "Alert": """Create an `Alert` from an HTTP request envelope containing a Pub/Sub message, as received by a Cloud Run module. Example code for a Cloud Run module that uses this method to open a ZTF alert: @@ -148,8 +148,8 @@ def index(): @classmethod def from_dict( cls, - payload: dict, - attributes: Optional[Union[dict, "google._upb._message.ScalarMapContainer"]] = None, + payload: Dict, + attributes: Optional[Union[Dict, "google._upb._message.ScalarMapContainer"]] = None, schema_name: Optional[str] = None, ) -> "Alert": # [TODO] update tom_desc to use this """Create an `Alert` from a dictionary (`payload`).""" @@ -173,7 +173,7 @@ def from_path(cls, path: Union[str, Path], schema_name: Optional[str] = None) -> # ---- properties ---- # @property - def attributes(self) -> dict: + def attributes(self) -> Dict: """Custom metadata for the message. Pub/Sub handles this as a dict-like called "attributes". If this was not set when the `Alert` was instantiated, a new dictionary will be created using @@ -187,7 +187,7 @@ def attributes(self) -> dict: return self._attributes @property - def dict(self) -> dict: + def dict(self) -> Dict: """Alert data as a dictionary. Created from `self.msg.data`, if needed. Raises