Skip to content

Commit

Permalink
fix: resolve unbound local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejgray committed Jun 8, 2024
1 parent f1e1c6d commit 1753f44
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ovos_config/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def show(user, system, remote, section, list_sections):
# based on chosen configuration
if name != "Joined":
_sections = [k for k, v in config.items() if isinstance(v, dict)]
if len([k for k, v in config.items() if not isinstance(v, dict)]):
if [k for k, v in config.items() if not isinstance(v, dict)]:
_sections.append("base")
else:
_sections = SECTIONS
Expand Down Expand Up @@ -241,7 +241,7 @@ def get(key):
@config.command()
@click.option("--key", "-k", required=True, help="the key (or parts thereof) which should be searched")
@click.option("--value", "-v", help="value the key should get associated with")
def set(key, value):
def set_config_key(key, value):
"""\b
Sets a config key in the user configuration
\b
Expand Down Expand Up @@ -275,7 +275,7 @@ def set(key, value):
console.print("User exit", style="red")
exit()
elif not paths:
console.print(f"[red]Error:[/red] No key that fits the query")
console.print("[red]Error:[/red] No key that fits the query")
exit()
else:
choice = 0
Expand All @@ -292,6 +292,8 @@ def set(key, value):
f"(type: [red]{selected_type}[/red]) "))
value = value.replace('"','').replace("'","").replace("`","")

local_conf = CONFIGS[2][1]
_value = None
# type checking/casting
try:
if isinstance(selected_value, str):
Expand Down Expand Up @@ -319,8 +321,7 @@ def set(key, value):
except (TypeError, ValueError):
console.print(f"[red]Error:[/red] The value passed can't be cast into {selected_type}")
exit()

local_conf = CONFIGS[2][1]

pathSet(local_conf, selected_path, _value)
local_conf.store()

Expand Down

0 comments on commit 1753f44

Please sign in to comment.