Skip to content

Commit 751a9f4

Browse files
committed
Lint files change find verbage
1 parent 98edf52 commit 751a9f4

3 files changed

Lines changed: 147 additions & 99 deletions

File tree

examples/get_messages.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import os
22
import asyncio
3-
from dotenv import load_dotenv #
3+
from dotenv import load_dotenv #
44
import postmark
55

66

77
# Load the variables from the .env file into os.environ
88
load_dotenv()
99

10+
1011
async def find():
1112
server_token: str = os.getenv("POSTMARK_SERVER_TOKEN")
12-
13+
1314
try:
14-
messages, total = await postmark.messages.Outbound.find(server_token=server_token)
15+
messages, total = await postmark.messages.Outbound.find(
16+
server_token=server_token
17+
)
1518
print(messages)
1619
print(f"Found {total} messages, retrieved {len(messages)} messages.")
1720
if messages:
@@ -22,13 +25,14 @@ async def find():
2225
print(f" DATE: {msg.received_at}")
2326
else:
2427
print("No messages found")
25-
28+
2629
except Exception as e:
2730
print(f"Error: {e}")
2831

32+
2933
async def find_all():
3034
server_token: str = os.getenv("POSTMARK_SERVER_TOKEN")
31-
35+
3236
try:
3337
messages = await postmark.messages.Outbound.find_all(server_token=server_token)
3438
print(f"Found messages, retrieved {len(messages)} messages.")
@@ -40,10 +44,11 @@ async def find_all():
4044
print(f" DATE: {msg.received_at}")
4145
else:
4246
print("No messages found")
43-
47+
4448
except Exception as e:
4549
print(f"Error: {e}")
4650

51+
4752
if __name__ == "__main__":
48-
# asyncio.run(find())
49-
asyncio.run(find_all())
53+
asyncio.run(find())
54+
# asyncio.run(find_all())

postmark/models/messages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ def validate_formatted_email(v: str) -> str:
2727
"""
2828
Validate email fields that may contain formatted strings like "Name" <email@example.com>
2929
"""
30-
if not v:
31-
return v
30+
31+
if v is None: # None
32+
raise ValueError("Email cannot be None")
33+
if not v: # Empty string
34+
raise ValueError("Email cannot be empty")
3235

3336
# Extract email from formats like: "Name" <email@example.com> or just email@example.com
3437
email_pattern = r'<([^>]+)>|([^\s<>"]+@[^\s<>"]+)'

0 commit comments

Comments
 (0)