Skip to content

Commit 69c08d1

Browse files
committed
Remove the need for calling dotenv manually by using pydantic
1 parent 9fa1fb3 commit 69c08d1

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

bot/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
try:
2-
from dotenv import load_dotenv
3-
print("Found .env file, loading environment variables from it.") # noqa: T201
4-
load_dotenv(override=True)
5-
except ModuleNotFoundError:
6-
pass
7-
81
import asyncio
92
import os
103
from typing import TYPE_CHECKING

bot/constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434

3535
PYTHON_PREFIX = "!"
36+
GIT_SHA = environ.get("GIT_SHA", "development")
3637

3738

3839
class EnvConfig(
@@ -90,6 +91,7 @@ class _Client(EnvConfig, env_prefix="client_"):
9091
github_repo: str = "https://github.com/python-discord/sir-lancebot"
9192
# Override seasonal locks: 1 (January) to 12 (December)
9293
month_override: int | None = None
94+
sentry_dsn: str = ""
9395

9496

9597
Client = _Client()

bot/log.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sentry_sdk.integrations.logging import LoggingIntegration
1111
from sentry_sdk.integrations.redis import RedisIntegration
1212

13-
from bot.constants import Logging
13+
from bot.constants import Client, GIT_SHA, Logging
1414

1515

1616
def setup() -> None:
@@ -59,12 +59,12 @@ def setup_sentry() -> None:
5959
)
6060

6161
sentry_sdk.init(
62-
dsn=os.environ.get("BOT_SENTRY_DSN"),
62+
dsn=Client.sentry_dsn,
6363
integrations=[
6464
sentry_logging,
6565
RedisIntegration(),
6666
],
67-
release=f"bot@{os.environ.get('GIT_SHA')}",
67+
release=f"bot@{GIT_SHA}",
6868
traces_sample_rate=0.5,
6969
_experiments={
7070
"profiles_sample_rate": 0.5,

0 commit comments

Comments
 (0)