Skip to content

Commit f1acf19

Browse files
committed
Fix ruff
1 parent ab8081c commit f1acf19

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

backend/onyx/connectors/zulip/connector.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import tempfile
33
import urllib.parse
44
from collections.abc import Generator
5+
from datetime import datetime
6+
from datetime import timezone
57
from typing import Any
8+
from typing import Dict
69
from typing import List
710
from typing import Tuple
8-
from typing import Dict, Union
9-
from datetime import datetime, timezone
11+
from typing import Union
1012

1113
from zulip import Client
1214

@@ -42,30 +44,30 @@ def __init__(
4244

4345
# Clean and normalize the URL
4446
realm_url = realm_url.strip().lower()
45-
47+
4648
# Remove any trailing slashes
47-
realm_url = realm_url.rstrip('/')
48-
49+
realm_url = realm_url.rstrip("/")
50+
4951
# Ensure the URL has a scheme
50-
if not realm_url.startswith(('http://', 'https://')):
51-
realm_url = f'https://{realm_url}'
52-
52+
if not realm_url.startswith(("http://", "https://")):
53+
realm_url = f"https://{realm_url}"
54+
5355
try:
5456
parsed = urllib.parse.urlparse(realm_url)
55-
57+
5658
# Extract the base domain without any paths or ports
57-
netloc = parsed.netloc.split(':')[0] # Remove port if present
58-
59+
netloc = parsed.netloc.split(":")[0] # Remove port if present
60+
5961
if not netloc:
6062
raise ValueError(
6163
f"Invalid realm URL format: {realm_url}. "
6264
f"URL must include a valid domain name."
6365
)
64-
66+
6567
# Always use HTTPS for security
6668
self.base_url = f"https://{netloc}"
6769
self.client: Client | None = None
68-
70+
6971
except Exception as e:
7072
raise ValueError(
7173
f"Failed to parse Zulip realm URL: {realm_url}. "
@@ -151,7 +153,7 @@ def _message_to_doc(self, message: Message) -> Document:
151153
"has_reactions": str(len(message.reactions) > 0),
152154
"content_type": str(message.content_type or "text"),
153155
}
154-
156+
155157
# Always include edit timestamp in metadata when available
156158
if edit_time is not None:
157159
metadata["edit_timestamp"] = str(message.last_edit_timestamp)

0 commit comments

Comments
 (0)