r-ss / foldwrap_backend

backend part of my Foldwrap project
https://foldwrap.com
0 stars 0 forks source link

config.py review suggestions #1

Open Sheihesinusslon opened 9 months ago

Sheihesinusslon commented 9 months ago

https://github.com/r-ss/foldwrap_backend/blob/5c4437e439ad34e534e4b05bd16d9c2818b86d4e/src/config.py#L11

PRODUCTION False or True should rather be taken from env variables. Also, a better idea is to have ENV constant variable reading DEV or PROD from env variables

https://github.com/r-ss/foldwrap_backend/blob/5c4437e439ad34e534e4b05bd16d9c2818b86d4e/src/config.py#L27

Print statements should be avoided. If you really need to use this info, use log

https://github.com/r-ss/foldwrap_backend/blob/5c4437e439ad34e534e4b05bd16d9c2818b86d4e/src/config.py#L79-L83

While you work on the project just by ourself, it can be fine but try not to push commented code in the repo at all. Usually, it´s confusing why a developer decided to keep it.

Typing: TELEGRAM_BOT_TOKEN: str = None should be TELEGRAM_BOT_TOKEN: Optional[str] = None or pydantic maybe even allows just to keep it as TELEGRAM_BOT_TOKEN: Optional[str] and it will be initialized with None value

TIP

r-ss commented 9 months ago

TELEGRAM_BOT_TOKEN: str = None should be TELEGRAM_BOT_TOKEN: Optional[str] = None

I actually want the application to crash if the token or any other env var is not set or not read, because that means there is something wrong with the variables and their loading, which means other critical variables like the database host may not be set either and you have to go and look in that place.