Skip to content

Commit f77a633

Browse files
committed
refactor
1 parent 4ba50ff commit f77a633

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

django_mongodb/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def check_django_compatability():
2828

2929
def parse(uri, **kwargs):
3030
uri = parse_uri(uri)
31+
3132
host = None
3233
port = None
3334

@@ -37,20 +38,18 @@ def parse(uri, **kwargs):
3738
else:
3839
# If the fqdn is not present, this is a standard URI and the host and
3940
# port are in the nodelist.
40-
host, port = [f"{node[0]}:{node[1]}" for node in uri["nodelist"]].next().split(":")
41+
host, port = [f"{node[0]}:{node[1]}" for node in uri["nodelist"]][0].split(":") # noqa: RUF015
4142

4243
settings_dict = {
4344
"ENGINE": "django_mongodb",
4445
"NAME": uri["database"],
4546
"HOST": host,
47+
"PORT": port,
4648
"USER": uri.get("username"),
4749
"PASSWORD": uri.get("password"),
4850
"OPTIONS": uri.get("options"),
4951
}
5052

51-
if port:
52-
settings_dict["PORT"] = port
53-
5453
if kwargs:
5554
settings_dict.update(kwargs)
5655

0 commit comments

Comments
 (0)