Skip to content

Commit

Permalink
Fix bug in _create_default_client. Make dotenv package optional in _c…
Browse files Browse the repository at this point in the history
…reate_default_client.
  • Loading branch information
fkdosilovic committed Nov 3, 2024
1 parent 225a286 commit 2a67cb4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/judge0/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from dotenv import load_dotenv

from .clients import (
async_execute,
ATDJudge0CE,
Expand Down Expand Up @@ -39,10 +37,12 @@


def _create_default_client():
if globals().get("judge0_default_client") is not None:
return
try:
from dotenv import load_dotenv

load_dotenv()
load_dotenv()
except: # noqa: E722
pass

rapid_api_key = os.getenv("JUDGE0_RAPID_API_KEY")
sulu_api_key = os.getenv("JUDGE0_SULU_API_KEY")
Expand All @@ -53,12 +53,11 @@ def _create_default_client():
elif sulu_api_key is not None:
client = SuluJudge0CE(api_key=sulu_api_key)
elif atd_api_key is not None:
client = ATDJudge0CE(api_key=sulu_api_key)
client = ATDJudge0CE(api_key=atd_api_key)
else:
client = None

if client is not None:
globals()["judge0_default_client"] = client
globals()["judge0_default_client"] = client


_create_default_client()

0 comments on commit 2a67cb4

Please sign in to comment.