diff --git a/.ruff.toml b/.ruff.toml index 0a1d8e9..51618ff 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -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 @@ -26,6 +32,7 @@ select = [ "E", # pycodestyle "F", # pyflakes/autoflake "FLY", # flynt + "FURB", # refurb "G", # flake8-logging-format "I", # isort "INP", # flake8-no-pep420 @@ -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 @@ -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] diff --git a/custom_components/pirateweather/__init__.py b/custom_components/pirateweather/__init__.py index b847d9b..ace3243 100644 --- a/custom_components/pirateweather/__init__.py +++ b/custom_components/pirateweather/__init__.py @@ -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))) @@ -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] diff --git a/custom_components/pirateweather/manifest.json b/custom_components/pirateweather/manifest.json index e2c8ef6..066764d 100644 --- a/custom_components/pirateweather/manifest.json +++ b/custom_components/pirateweather/manifest.json @@ -12,5 +12,5 @@ "requirements": [ "python-forecastio==1.4.0" ], - "version": "1.5.6" + "version": "1.5.7" }