Skip to content

Commit f0415b1

Browse files
author
Adriano Sanges
committed
Refactor environment variable loading in scan_properties.py and telegram_api.py
- Simplify the loading of environment variables by directly calling load_dotenv() without checking multiple file paths - Improve code clarity and maintainability by removing redundant functions
1 parent 4a00122 commit f0415b1

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

real-estate-etl/scan_properties.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77
import os
88
from telegram_api import send_message, format_property_message
99

10-
def load_env_file():
11-
if os.path.exists("../.env"):
12-
load_dotenv("../.env")
13-
elif os.path.exists("../files/.env"):
14-
load_dotenv("../files/.env")
15-
else:
16-
print("Warning: No .env file found in ../.env or ../files/.env")
17-
18-
load_env_file()
10+
load_dotenv()
1911

2012
if __name__ == "__main__":
2113

real-estate-etl/telegram_api.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
from typing import Dict, Any
44
from dotenv import load_dotenv
55

6-
def load_env_file():
7-
if os.path.exists("../.env"):
8-
load_dotenv("../.env")
9-
elif os.path.exists("../files/.env"):
10-
load_dotenv("../files/.env")
11-
else:
12-
print("Warning: No .env file found in ../.env or ../files/.env")
13-
14-
load_env_file()
6+
load_dotenv()
157

168
TELEGRAM_BOT_API_KEY: str = os.getenv("telegram_bot_api_key")
179

0 commit comments

Comments
 (0)