Skip to content

Commit

Permalink
Remove scope name shadow (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseymour authored May 29, 2022
1 parent aba6a67 commit 389febf
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ def config(
env=DEFAULT_ENV, default=None, engine=None, conn_max_age=0, ssl_require=False
):
"""Returns configured DATABASE dictionary from DATABASE_URL."""

config = {}

s = os.environ.get(env, default)

if s:
config = parse(s, engine, conn_max_age, ssl_require)
return parse(s, engine, conn_max_age, ssl_require)

return config
return {}


def parse(url, engine=None, conn_max_age=0, ssl_require=False):
Expand All @@ -82,7 +79,7 @@ def parse(url, engine=None, conn_max_age=0, ssl_require=False):
# note: no other settings are required for sqlite

# otherwise parse the url as normal
config = {}
parsed_config = {}

url = urlparse.urlparse(url)

Expand Down Expand Up @@ -121,7 +118,7 @@ def parse(url, engine=None, conn_max_age=0, ssl_require=False):
)

# Update with environment configuration.
config.update(
parsed_config.update(
{
"NAME": urlparse.unquote(path or ""),
"USER": urlparse.unquote(url.username or ""),
Expand Down Expand Up @@ -154,9 +151,9 @@ def parse(url, engine=None, conn_max_age=0, ssl_require=False):
options["options"] = "-c search_path={0}".format(options.pop("currentSchema"))

if options:
config["OPTIONS"] = options
parsed_config["OPTIONS"] = options

if engine:
config["ENGINE"] = engine
parsed_config["ENGINE"] = engine

return config
return parsed_config

0 comments on commit 389febf

Please sign in to comment.