1515import re
1616from collections import defaultdict
1717from datetime import datetime
18- from typing import Any , Dict , Final , List , Optional , Union
18+ from typing import Any , Final , Optional , Union
1919
2020from cloudevents .core .base import BaseCloudEvent
2121from cloudevents .core .v1 .exceptions import (
3939class CloudEvent (BaseCloudEvent ):
4040 def __init__ (
4141 self ,
42- attributes : Dict [str , Any ],
43- data : Optional [Union [Dict [str , Any ], str , bytes ]] = None ,
42+ attributes : dict [str , Any ],
43+ data : Optional [Union [dict [str , Any ], str , bytes ]] = None ,
4444 ) -> None :
4545 self ._validate_attribute (attributes = attributes )
46- self ._attributes : Dict [str , Any ] = attributes
47- self ._data : Optional [Union [Dict [str , Any ], str , bytes ]] = data
46+ self ._attributes : dict [str , Any ] = attributes
47+ self ._data : Optional [Union [dict [str , Any ], str , bytes ]] = data
4848
4949 @staticmethod
50- def _validate_attribute (attributes : Dict [str , Any ]) -> None :
50+ def _validate_attribute (attributes : dict [str , Any ]) -> None :
5151 """
5252 Validates the attributes of the CloudEvent as per the CloudEvents specification.
5353
@@ -62,15 +62,15 @@ def _validate_attribute(attributes: Dict[str, Any]) -> None:
6262
6363 @staticmethod
6464 def _validate_required_attributes (
65- attributes : Dict [str , Any ],
66- ) -> Dict [str , List [BaseCloudEventException ]]:
65+ attributes : dict [str , Any ],
66+ ) -> dict [str , list [BaseCloudEventException ]]:
6767 """
6868 Validates the types of the required attributes.
6969
7070 :param attributes: The attributes of the CloudEvent instance.
7171 :return: A dictionary of validation error messages.
7272 """
73- errors : Dict [str , List [BaseCloudEventException ]] = defaultdict (list )
73+ errors : dict [str , list [BaseCloudEventException ]] = defaultdict (list )
7474
7575 if "id" not in attributes :
7676 errors ["id" ].append (MissingRequiredAttributeError (attribute_name = "id" ))
@@ -122,15 +122,15 @@ def _validate_required_attributes(
122122
123123 @staticmethod
124124 def _validate_optional_attributes (
125- attributes : Dict [str , Any ],
126- ) -> Dict [str , List [BaseCloudEventException ]]:
125+ attributes : dict [str , Any ],
126+ ) -> dict [str , list [BaseCloudEventException ]]:
127127 """
128128 Validates the types and values of the optional attributes.
129129
130130 :param attributes: The attributes of the CloudEvent instance.
131131 :return: A dictionary of validation error messages.
132132 """
133- errors : Dict [str , List [BaseCloudEventException ]] = defaultdict (list )
133+ errors : dict [str , list [BaseCloudEventException ]] = defaultdict (list )
134134
135135 if "time" in attributes :
136136 if not isinstance (attributes ["time" ], datetime ):
@@ -192,15 +192,15 @@ def _validate_optional_attributes(
192192
193193 @staticmethod
194194 def _validate_extension_attributes (
195- attributes : Dict [str , Any ],
196- ) -> Dict [str , List [BaseCloudEventException ]]:
195+ attributes : dict [str , Any ],
196+ ) -> dict [str , list [BaseCloudEventException ]]:
197197 """
198198 Validates the extension attributes.
199199
200200 :param attributes: The attributes of the CloudEvent instance.
201201 :return: A dictionary of validation error messages.
202202 """
203- errors : Dict [str , List [BaseCloudEventException ]] = defaultdict (list )
203+ errors : dict [str , list [BaseCloudEventException ]] = defaultdict (list )
204204 extension_attributes = [
205205 key
206206 for key in attributes .keys ()
@@ -257,8 +257,8 @@ def get_time(self) -> Optional[datetime]:
257257 def get_extension (self , extension_name : str ) -> Any :
258258 return self ._attributes .get (extension_name )
259259
260- def get_data (self ) -> Optional [Union [Dict [str , Any ], str , bytes ]]:
260+ def get_data (self ) -> Optional [Union [dict [str , Any ], str , bytes ]]:
261261 return self ._data
262262
263- def get_attributes (self ) -> Dict [str , Any ]:
263+ def get_attributes (self ) -> dict [str , Any ]:
264264 return self ._attributes
0 commit comments