Skip to content

Commit 178967f

Browse files
committed
add type annotation in test
1 parent e222796 commit 178967f

25 files changed

+93
-91
lines changed

eventsourcingdb/errors/client_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class ClientError(CustomError):
5-
def __init__(self, cause: str):
5+
def __init__(self, cause: str) -> None:
66
super().__init__(f'Client error occurred: {cause}')

eventsourcingdb/errors/internal_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class InternalError(CustomError):
5-
def __init__(self, cause: str):
5+
def __init__(self, cause: str) -> None:
66
super().__init__(f'Internal error occurred: {cause}')

eventsourcingdb/errors/server_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class ServerError(CustomError):
5-
def __init__(self, cause: str):
5+
def __init__(self, cause: str) -> None:
66
super().__init__(f'Server error occurred: {cause}')

eventsourcingdb/errors/validation_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
class ValidationError(CustomError):
5-
def __init__(self, cause: str):
5+
def __init__(self, cause: str) -> None:
66
super().__init__(f'Validation error occurred: {cause}')

eventsourcingdb/event/event.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import datetime
22
from dataclasses import dataclass
3-
from typing import TypeVar
3+
from typing import TypeVar, Any
44

55
from ..errors.internal_error import InternalError
66
from ..errors.validation_error import ValidationError
@@ -24,7 +24,7 @@ class Event():
2424
trace_state: str | None = None
2525

2626
@staticmethod
27-
def parse(unknown_object: dict) -> "Event":
27+
def parse(unknown_object: dict) -> 'Event':
2828
source = unknown_object.get('source')
2929
if not isinstance(source, str):
3030
raise ValidationError(
@@ -103,7 +103,7 @@ def parse(unknown_object: dict) -> "Event":
103103
trace_state=trace_state
104104
)
105105

106-
def to_json(self):
106+
def to_json(self) -> dict[str, Any]:
107107
json = {
108108
'specversion': self.spec_version,
109109
'id': self.event_id,

eventsourcingdb/event/event_candidate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
2+
from typing import Any
33

44
@dataclass
55
class EventCandidate:
@@ -10,7 +10,7 @@ class EventCandidate:
1010
trace_parent: str | None = None
1111
trace_state: str | None = None
1212

13-
def to_json(self):
13+
def to_json(self) -> dict[str, Any]:
1414
json = {
1515
'data': self.data,
1616
'source': self.source,

eventsourcingdb/http_client/http_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ def __init__(
1515
self,
1616
base_url: str,
1717
api_token: str,
18-
):
18+
) -> None:
1919
self.__base_url = base_url
2020
self.__api_token = api_token
2121
self.__session: ClientSession | None = None
2222

23-
async def __aenter__(self):
23+
async def __aenter__(self) -> 'HttpClient':
2424
await self.initialize()
2525
return self
2626

@@ -35,7 +35,7 @@ async def __aexit__(
3535
async def initialize(self) -> None:
3636
self.__session = aiohttp.ClientSession()
3737

38-
async def close(self):
38+
async def close(self) -> None:
3939
if self.__session is not None:
4040
await self.__session.close()
4141
self.__session = None

eventsourcingdb/http_client/response.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88

99

1010
class Response:
11-
def __init__(self, response: aiohttp.ClientResponse):
11+
def __init__(self, response: aiohttp.ClientResponse) -> None:
1212
self.__response: aiohttp.ClientResponse = response
1313

14-
async def __aenter__(self):
15-
# Properly await any async initialization if needed
14+
async def __aenter__(self) -> 'Response':
1615
return self
1716

18-
async def __aexit__(self, exc_type, exc_val, exc_tb):
17+
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
1918
if not self.__response.closed:
2019
self.__response.close()
2120

22-
def __enter__(self):
21+
def __enter__(self) -> 'Response':
2322
return self
2423

25-
def __exit__(self, exc_type, exc_val, exc_tb):
24+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
2625
if not self.__response.closed:
2726
self.__response.close()
2827

eventsourcingdb/observe_events/observe_from_latest_event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import Any
23

34
from .if_event_is_missing_during_observe import IfEventIsMissingDuringObserve
45

@@ -9,7 +10,7 @@ class ObserveFromLatestEvent:
910
type: str
1011
if_event_is_missing: IfEventIsMissingDuringObserve
1112

12-
def to_json(self):
13+
def to_json(self) -> dict[str, Any]:
1314
return {
1415
'subject': self.subject,
1516
'type': self.type,

eventsourcingdb/read_event_types/event_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class EventType:
1313
schema: dict[str, Any] | None = None
1414

1515
@staticmethod
16-
def parse(unknown_object: dict) -> "EventType":
16+
def parse(unknown_object: dict) -> 'EventType':
1717
event_type = unknown_object.get('eventType')
1818
if not isinstance(event_type, str):
1919
raise ValidationError(
@@ -38,7 +38,7 @@ def parse(unknown_object: dict) -> "EventType":
3838
schema=schema,
3939
)
4040

41-
def __hash__(self):
41+
def __hash__(self) -> str:
4242
# Convert dictionary schema to a hashable form (tuple of items)
4343
if isinstance(self.schema, dict):
4444
# Sort items to ensure consistent hashing

0 commit comments

Comments
 (0)