Skip to content

Commit

Permalink
fix: remove unnecessary Union types
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshultz committed Nov 27, 2023
1 parent 40a2041 commit 0f630b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions silverback/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from taskiq import TaskiqResult
from typing_extensions import Self # Introduced 3.11

from .types import IntOrNone, SilverbackIdent
from .types import SilverbackIdent

_HandlerReturnType = TypeVar("_HandlerReturnType")

Expand Down Expand Up @@ -37,8 +37,8 @@ def from_taskiq(
cls,
ident: SilverbackIdent,
handler_id: str,
block_number: IntOrNone,
log_index: IntOrNone,
block_number: Optional[int],
log_index: Optional[int],
result: TaskiqResult,
) -> Self:
return cls(
Expand Down
8 changes: 2 additions & 6 deletions silverback/types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from typing import Optional, Protocol, Union
from typing import Optional, Protocol

from pydantic import BaseModel
from typing_extensions import Self # Introduced 3.11

# NOTE: 'type | None' introduced in 3.10
StrOrNone = Union[str, None]
IntOrNone = Union[int, None]


class ISilverbackSettings(Protocol):
"""Loose approximation of silverback.settings.Settings. If you can, use the class as
Expand Down Expand Up @@ -40,7 +36,7 @@ def handler_id_block(block_number: Optional[int]) -> str:
return f"block/{block_number}"


def handler_id_event(contract_address: StrOrNone, event_signature: str) -> str:
def handler_id_event(contract_address: Optional[str], event_signature: str) -> str:
"""Return a unique handler ID string for an event"""
# TODO: Under what circumstance can address be None?
return f"event/{contract_address or 'unknown'}/{event_signature}"

0 comments on commit 0f630b0

Please sign in to comment.