From 8abd6b268b67568ba613c062d9c874b646d41bea Mon Sep 17 00:00:00 2001 From: Sameer Wagh Date: Wed, 31 Jul 2024 09:36:29 -0400 Subject: [PATCH 1/2] BaseNotifier class made pydantic safe (with backward edits) --- packages/syft/src/syft/service/notifier/notifier.py | 5 +++-- packages/syft/src/syft/service/notifier/smtp_client.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/syft/src/syft/service/notifier/notifier.py b/packages/syft/src/syft/service/notifier/notifier.py index 6cc24a3d720..7e9e1fcc9e2 100644 --- a/packages/syft/src/syft/service/notifier/notifier.py +++ b/packages/syft/src/syft/service/notifier/notifier.py @@ -11,6 +11,7 @@ from typing import TypeVar # third party +from pydantic import BaseModel from result import Err from result import Ok from result import Result @@ -28,7 +29,7 @@ from .smtp_client import SMTPClient -class BaseNotifier: +class BaseNotifier(BaseModel): def send( self, target: SyftVerifyKey, notification: Notification ) -> SyftSuccess | SyftError: @@ -41,7 +42,7 @@ def send( @serializable(canonical_name="EmailNotifier", version=1) class EmailNotifier(BaseNotifier): smtp_client: SMTPClient - sender = "" + sender: str = "" def __init__( self, diff --git a/packages/syft/src/syft/service/notifier/smtp_client.py b/packages/syft/src/syft/service/notifier/smtp_client.py index 1f4df6531e5..9c71f328b27 100644 --- a/packages/syft/src/syft/service/notifier/smtp_client.py +++ b/packages/syft/src/syft/service/notifier/smtp_client.py @@ -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: float = 5 # seconds def __init__( self, From 4fc02d99524abf97a58db8fa74aefcdb9cc96feb Mon Sep 17 00:00:00 2001 From: Sameer Wagh Date: Wed, 31 Jul 2024 14:43:58 -0400 Subject: [PATCH 2/2] Changing dtype to int --- packages/syft/src/syft/service/notifier/smtp_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/syft/src/syft/service/notifier/smtp_client.py b/packages/syft/src/syft/service/notifier/smtp_client.py index 9c71f328b27..f7041c9f722 100644 --- a/packages/syft/src/syft/service/notifier/smtp_client.py +++ b/packages/syft/src/syft/service/notifier/smtp_client.py @@ -11,7 +11,7 @@ class SMTPClient(BaseModel): - SOCKET_TIMEOUT: float = 5 # seconds + SOCKET_TIMEOUT: int = 5 # seconds def __init__( self,