Skip to content

Commit

Permalink
Merge pull request #9107 from OpenMined/snwagh/base-notifier-class-py…
Browse files Browse the repository at this point in the history
…dantic

BaseNotifier class made pydantic safe (with backward edits)
  • Loading branch information
snwagh authored Aug 1, 2024
2 parents 5ebe163 + 7d14309 commit 2fac62d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/syft/src/syft/service/notifier/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import TypeVar

# third party
from pydantic import BaseModel
from result import Err
from result import Ok
from result import Result
Expand All @@ -33,7 +34,7 @@
from .smtp_client import SMTPClient


class BaseNotifier:
class BaseNotifier(BaseModel):
def send(
self, target: SyftVerifyKey, notification: Notification
) -> SyftSuccess | SyftError:
Expand All @@ -54,7 +55,7 @@ class UserNotificationActivity(SyftObject):
@serializable(canonical_name="EmailNotifier", version=1)
class EmailNotifier(BaseNotifier):
smtp_client: SMTPClient
sender = ""
sender: str = ""

def __init__(
self,
Expand Down
5 changes: 3 additions & 2 deletions packages/syft/src/syft/service/notifier/smtp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import smtplib

# third party
from pydantic import BaseModel
from result import Err
from result import Ok
from result import Result


class SMTPClient:
SOCKET_TIMEOUT = 5 # seconds
class SMTPClient(BaseModel):
SOCKET_TIMEOUT: int = 5 # seconds

def __init__(
self,
Expand Down

0 comments on commit 2fac62d

Please sign in to comment.