-
Notifications
You must be signed in to change notification settings - Fork 25
Simplify get_database_url default handling with or #645
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestpriority:lowNice-to-have improvement. Can be deferred without blocking other work.Nice-to-have improvement. Can be deferred without blocking other work.pythonPull requests that update Python codePull requests that update Python codepython:idiomsRefactors toward idiomatic Python (PEP conventions, stdlib idioms)Refactors toward idiomatic Python (PEP conventions, stdlib idioms)
Description
Activity
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpriority:lowNice-to-have improvement. Can be deferred without blocking other work.Nice-to-have improvement. Can be deferred without blocking other work.pythonPull requests that update Python codePull requests that update Python codepython:idiomsRefactors toward idiomatic Python (PEP conventions, stdlib idioms)Refactors toward idiomatic Python (PEP conventions, stdlib idioms)
Problem
databases/player_database.py::get_database_url:The "declare, then reassign inside an
if" shape is a common C#-ism. Pythonexpresses "use this, otherwise the fallback" with
or.Proposed Solution
Semantic nuance worth understanding (and maybe a comment):
ortreats anempty-string
DATABASE_URLas unset — same as the currentif not database_url. If "set but empty" should be distinct from "unset", the test isos.getenv("DATABASE_URL") is Noneinstead.Suggested Approach
orexpression above.DATABASE_URL/_connect_argslogic downstreamunchanged.
uv run pytest.Acceptance Criteria
get_database_urlreturns a singleorexpressionDATABASE_URLstill falls back to SQLiteSTORAGE_PATHoverride still honouredCHANGELOG.mdupdatedReferences
or)os.getenv