Skip to content

Commit 2a67cb4

Browse files
committed
Fix bug in _create_default_client. Make dotenv package optional in _create_default_client.
1 parent 225a286 commit 2a67cb4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/judge0/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
22

3-
from dotenv import load_dotenv
4-
53
from .clients import (
64
async_execute,
75
ATDJudge0CE,
@@ -39,10 +37,12 @@
3937

4038

4139
def _create_default_client():
42-
if globals().get("judge0_default_client") is not None:
43-
return
40+
try:
41+
from dotenv import load_dotenv
4442

45-
load_dotenv()
43+
load_dotenv()
44+
except: # noqa: E722
45+
pass
4646

4747
rapid_api_key = os.getenv("JUDGE0_RAPID_API_KEY")
4848
sulu_api_key = os.getenv("JUDGE0_SULU_API_KEY")
@@ -53,12 +53,11 @@ def _create_default_client():
5353
elif sulu_api_key is not None:
5454
client = SuluJudge0CE(api_key=sulu_api_key)
5555
elif atd_api_key is not None:
56-
client = ATDJudge0CE(api_key=sulu_api_key)
56+
client = ATDJudge0CE(api_key=atd_api_key)
5757
else:
5858
client = None
5959

60-
if client is not None:
61-
globals()["judge0_default_client"] = client
60+
globals()["judge0_default_client"] = client
6261

6362

6463
_create_default_client()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy