Skip to content

Commit 7991526

Browse files
committed
Use PositiveFloat instead of PositiveInt
1 parent 77fc371 commit 7991526

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ The service requires the following configuration parameters:
145145

146146
- **Any of**
147147

148-
- *integer*: Exclusive minimum: `0`.
148+
- *number*: Exclusive minimum: `0.0`.
149149

150150
- *null*
151151

config_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@
142142
"smtp_timeout": {
143143
"anyOf": [
144144
{
145-
"exclusiveMinimum": 0,
146-
"type": "integer"
145+
"exclusiveMinimum": 0.0,
146+
"type": "number"
147147
},
148148
{
149149
"type": "null"

src/ns/adapters/outbound/smtp_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from email.message import EmailMessage
2424
from smtplib import SMTP, SMTPAuthenticationError, SMTPException
2525

26-
from pydantic import BaseModel, Field, PositiveInt, SecretStr
26+
from pydantic import BaseModel, Field, PositiveFloat, SecretStr
2727
from pydantic_settings import BaseSettings
2828

2929
from ns.ports.outbound.smtp_client import SmtpClientPort
@@ -51,7 +51,7 @@ class SmtpClientConfig(BaseSettings):
5151
use_starttls: bool = Field(
5252
default=True, description="Boolean flag indicating the use of STARTTLS"
5353
)
54-
smtp_timeout: PositiveInt | None = Field(
54+
smtp_timeout: PositiveFloat | None = Field(
5555
default=None,
5656
description=(
5757
"The maximum amount of time (in seconds) to wait for a connection to the"
@@ -70,9 +70,7 @@ def __init__(self, *, config: SmtpClientConfig):
7070
@contextmanager
7171
def get_connection(self) -> Generator[SMTP, None, None]:
7272
"""Establish a connection to the SMTP server"""
73-
timeout = (
74-
float(self._config.smtp_timeout) if self._config.smtp_timeout else None
75-
)
73+
timeout = self._config.smtp_timeout if self._config.smtp_timeout else None
7674

7775
try:
7876
log.debug("Attempting to establish SMTP connection (timeout=%s).", timeout)

0 commit comments

Comments
 (0)