mirror of
https://github.com/hacs/integration.git
synced 2025-07-22 00:35:16 +00:00
Bump black to 23.1.0 and target 3.9 (#3061)
This commit is contained in:
2
.github/pre-commit-config.yaml
vendored
2
.github/pre-commit-config.yaml
vendored
@ -14,7 +14,7 @@ repos:
|
||||
name: isort (python)
|
||||
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.6.0
|
||||
rev: 23.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
stages: [manual]
|
||||
|
@ -457,7 +457,9 @@ class HacsBase:
|
||||
|
||||
try:
|
||||
await self.hass.async_add_executor_job(_write_file)
|
||||
except BaseException as error: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as error:
|
||||
self.log.error("Could not write data to %s - %s", file_path, error)
|
||||
return False
|
||||
|
||||
@ -476,7 +478,9 @@ class HacsBase:
|
||||
f"{reset.hour}:{reset.minute}:{reset.second}",
|
||||
)
|
||||
self.disable_hacs(HacsDisabledReason.RATE_LIMIT)
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.log.exception(exception)
|
||||
|
||||
return 0
|
||||
@ -515,7 +519,9 @@ class HacsBase:
|
||||
raise exception
|
||||
except GitHubException as exception:
|
||||
_exception = exception
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.log.exception(exception)
|
||||
_exception = exception
|
||||
|
||||
@ -726,7 +732,9 @@ class HacsBase:
|
||||
await asyncio.sleep(1)
|
||||
continue
|
||||
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.log.exception("Download failed - %s", exception)
|
||||
|
||||
return None
|
||||
|
@ -25,7 +25,7 @@ class RestartRequiredFixFlow(RepairsFlow):
|
||||
) -> data_entry_flow.FlowResult:
|
||||
"""Handle the first step of a fix flow."""
|
||||
|
||||
return await (self.async_step_confirm_restart())
|
||||
return await self.async_step_confirm_restart()
|
||||
|
||||
async def async_step_confirm_restart(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
|
@ -830,7 +830,9 @@ class HacsRepository:
|
||||
"%s Presumed local content path %s does not exist", self.string, local_path
|
||||
)
|
||||
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.logger.debug("%s Removing %s failed with %s", self.string, local_path, exception)
|
||||
return False
|
||||
return True
|
||||
@ -1247,7 +1249,9 @@ class HacsRepository:
|
||||
return
|
||||
self.validate.errors.append(f"[{content.name}] was not downloaded.")
|
||||
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.validate.errors.append(f"Download was not completed [{exception}]")
|
||||
|
||||
async def async_remove_entity_device(self) -> None:
|
||||
|
@ -74,7 +74,9 @@ class Backup:
|
||||
self.local_path,
|
||||
self.backup_path_full,
|
||||
)
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.hacs.log.warning("Could not create backup: %s", exception)
|
||||
|
||||
def restore(self) -> None:
|
||||
|
@ -241,7 +241,9 @@ class HacsData:
|
||||
self.async_restore_repository(entry, repo_data)
|
||||
|
||||
self.logger.info("<HacsData restore> Restore done")
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
self.logger.critical(
|
||||
"<HacsData restore> [%s] Restore Failed!", exception, exc_info=exception
|
||||
)
|
||||
|
@ -17,7 +17,9 @@ class HACSStore(Store):
|
||||
"""Load the data from disk if version matches."""
|
||||
try:
|
||||
data = json_util.load_json(self.path)
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
_LOGGER.critical(
|
||||
"Could not load '%s', restore it from a backup or delete the file: %s",
|
||||
self.path,
|
||||
|
@ -31,6 +31,8 @@ def render_template(hacs: HacsBase, content: str, context: HacsRepository) -> st
|
||||
version_available=context.releases.last_release,
|
||||
version_installed=context.display_installed_version,
|
||||
)
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
context.logger.debug(exception)
|
||||
return content
|
||||
|
@ -164,7 +164,9 @@ async def hacs_repositories_add(
|
||||
category=category,
|
||||
)
|
||||
|
||||
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
except (
|
||||
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
|
||||
) as exception:
|
||||
hacs.async_dispatch(
|
||||
HacsDispatchEvent.ERROR,
|
||||
{
|
||||
@ -175,7 +177,6 @@ async def hacs_repositories_add(
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
hacs.async_dispatch(
|
||||
HacsDispatchEvent.ERROR,
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.black]
|
||||
line-length = 100
|
||||
target-version = ['py38']
|
||||
target-version = ['py39']
|
||||
exclude = 'generated'
|
||||
|
||||
[tool.isort]
|
||||
|
@ -4,7 +4,6 @@ import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
MANIFEST_FILE = Path(f"{os.getcwd()}/custom_components/hacs/manifest.json")
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@ from custom_components.hacs.exceptions import HacsException
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_base(repository_appdaemon):
|
||||
|
||||
assert repository_appdaemon.data.category == "appdaemon"
|
||||
|
||||
|
||||
|
@ -151,7 +151,6 @@ async def test_registration_issues(
|
||||
|
||||
assert hacs.repositories.get_by_full_name(repository_full_name) is None
|
||||
with pytest.raises(HacsException, match=expected_message):
|
||||
|
||||
await hacs.async_register_repository(
|
||||
repository_full_name, HacsCategory.INTEGRATION, check=True
|
||||
)
|
||||
|
@ -61,7 +61,6 @@ async def test_store_store(hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
"custom_components.hacs.utils.store.json_util.load_json",
|
||||
return_value={"version": VERSION_STORAGE, "data": {}},
|
||||
):
|
||||
|
||||
await async_save_to_store(hass, "test", {})
|
||||
assert not async_save_mock.called
|
||||
assert (
|
||||
|
Reference in New Issue
Block a user