Skip to content

Commit

Permalink
Merge pull request #293 from Pirate-Weather/key-error-fix
Browse files Browse the repository at this point in the history
Fix scan_interval KeyError
  • Loading branch information
cloneofghosts committed Aug 18, 2024
2 parents 1af0a02 + 7591942 commit 87333d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
18 changes: 9 additions & 9 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ target-version = "py312"
[lint]
select = [
"A001", # Variable {name} is shadowing a Python builtin
"ASYNC210", # Async functions should not call blocking HTTP methods
"ASYNC220", # Async functions should not create subprocesses with blocking methods
"ASYNC221", # Async functions should not run processes with blocking methods
"ASYNC222", # Async functions should not wait on processes with blocking methods
"ASYNC230", # Async functions should not open files with blocking methods like open
"ASYNC251", # Async functions should not call time.sleep
"B002", # Python does not support the unary prefix increment
"B005", # Using .strip() with multi-character strings is misleading
"B007", # Loop control variable {name} not used within loop body
Expand All @@ -26,6 +32,7 @@ select = [
"E", # pycodestyle
"F", # pyflakes/autoflake
"FLY", # flynt
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"INP", # flake8-no-pep420
Expand All @@ -47,6 +54,7 @@ select = [
"RUF006", # Store a reference to the return value of asyncio.create_task
"RUF010", # Use explicit conversion flag
"RUF013", # PEP 484 prohibits implicit Optional
"RUF017", # Avoid quadratic list summation
"RUF018", # Avoid assignment expressions in assert statements
"RUF019", # Unnecessary key check before dictionary access
# "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
Expand Down Expand Up @@ -123,15 +131,7 @@ ignore = [
"ISC001",

# Disabled because ruff does not understand type of __all__ generated by a function
"PLE0605",

# temporarily disabled
"PT019",
"PYI024", # Use typing.NamedTuple instead of collections.namedtuple
"RET503",
"RET501",
"TRY002",
"TRY301"
"PLE0605"
]

[lint.flake8-pytest-style]
Expand Down
7 changes: 6 additions & 1 deletion custom_components/pirateweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
pw_entity_rounding = _get_config_value(entry, PW_ROUND)
pw_scan_Int = _get_config_value(entry, CONF_SCAN_INTERVAL)

if not pw_scan_Int:
pw_scan_Int = entry.data[CONF_SCAN_INTERVAL]

pw_scan_Int = max(pw_scan_Int, 60)

# Extract list of int from forecast days/ hours string if present
# _LOGGER.warning('forecast_days_type: ' + str(type(forecast_days)))

Expand Down Expand Up @@ -164,7 +169,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:


def _get_config_value(config_entry: ConfigEntry, key: str) -> Any:
if config_entry.options:
if config_entry.options and key in config_entry.options:
return config_entry.options[key]
return config_entry.data[key]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"requirements": [
"python-forecastio==1.4.0"
],
"version": "1.5.6"
"version": "1.5.7"
}

0 comments on commit 87333d2

Please sign in to comment.