From a1dcd7fb7f0b7465e5264d35693db679a09a95a3 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Fri, 28 Apr 2023 13:59:36 -0400 Subject: [PATCH] fix pylint issues --- supervisor/dbus/systemd.py | 2 ++ supervisor/mounts/manager.py | 2 +- tests/api/test_mounts.py | 8 ++++---- tests/dbus_service_mocks/systemd.py | 2 +- tests/mounts/test_manager.py | 4 ++-- tests/mounts/test_mount.py | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/supervisor/dbus/systemd.py b/supervisor/dbus/systemd.py index ea9594e9d..4ae5903a7 100644 --- a/supervisor/dbus/systemd.py +++ b/supervisor/dbus/systemd.py @@ -41,7 +41,9 @@ def systemd_errors(func): return await func(*args, **kwds) except DBusFatalError as err: if err.type == DBUS_ERR_SYSTEMD_NO_SUCH_UNIT: + # pylint: disable=raise-missing-from raise DBusSystemdNoSuchUnit(str(err)) + # pylint: enable=raise-missing-from raise err return wrapper diff --git a/supervisor/mounts/manager.py b/supervisor/mounts/manager.py index 55f4f929d..1384facf1 100644 --- a/supervisor/mounts/manager.py +++ b/supervisor/mounts/manager.py @@ -87,7 +87,7 @@ class MountManager(FileConfiguration, CoreSysAttributes): *[mount.load() for mount in mounts], return_exceptions=True ) - for i in range(len(errors)): + for i in range(len(errors)): # pylint: disable=consider-using-enumerate if not errors[i]: continue if not isinstance(errors[i], MountError): diff --git a/tests/api/test_mounts.py b/tests/api/test_mounts.py index 92998cb03..41cc587b4 100644 --- a/tests/api/test_mounts.py +++ b/tests/api/test_mounts.py @@ -81,7 +81,7 @@ async def test_api_create_error_mount_exists(api_client: TestClient, mount): "share": "backups", }, ) - resp.status == 400 + assert resp.status == 400 result = await resp.json() assert result["result"] == "error" assert result["message"] == "A mount already exists with name backup_test" @@ -128,7 +128,7 @@ async def test_api_update_error_mount_missing(api_client: TestClient): "share": "new_backups", }, ) - resp.status == 400 + assert resp.status == 400 result = await resp.json() assert result["result"] == "error" assert result["message"] == "No mount exists with name backup_test" @@ -153,7 +153,7 @@ async def test_api_reload_mount( async def test_api_reload_error_mount_missing(api_client: TestClient): """Test reload mount API errors when mount does not exist.""" resp = await api_client.post("/mounts/backup_test/reload") - resp.status == 400 + assert resp.status == 400 result = await resp.json() assert result["result"] == "error" assert result["message"] == "No mount exists with name backup_test" @@ -176,7 +176,7 @@ async def test_api_delete_mount(api_client: TestClient, coresys: CoreSys, mount) async def test_api_delete_error_mount_missing(api_client: TestClient): """Test delete mount API errors when mount does not exist.""" resp = await api_client.delete("/mounts/backup_test") - resp.status == 400 + assert resp.status == 400 result = await resp.json() assert result["result"] == "error" assert result["message"] == "No mount exists with name backup_test" diff --git a/tests/dbus_service_mocks/systemd.py b/tests/dbus_service_mocks/systemd.py index b07b0db65..a70097be2 100644 --- a/tests/dbus_service_mocks/systemd.py +++ b/tests/dbus_service_mocks/systemd.py @@ -13,7 +13,7 @@ def setup(object_path: str | None = None) -> DBusServiceMock: return Systemd() -# pylint: disable=invalid-name,missing-function-docstring +# pylint: disable=invalid-name,missing-function-docstring,raising-bad-type class Systemd(DBusServiceMock): diff --git a/tests/mounts/test_manager.py b/tests/mounts/test_manager.py index ebc958543..46b448811 100644 --- a/tests/mounts/test_manager.py +++ b/tests/mounts/test_manager.py @@ -391,8 +391,8 @@ async def test_save_data(coresys: CoreSys, tmp_supervisor_data: Path, path_exter coresys.mounts.save_data() assert path.exists() - with path.open() as f: - config = json.load(f) + with path.open() as file: + config = json.load(file) assert config["mounts"] == [ { "name": "auth_test", diff --git a/tests/mounts/test_mount.py b/tests/mounts/test_mount.py index f4774cf75..8ce070e5c 100644 --- a/tests/mounts/test_mount.py +++ b/tests/mounts/test_mount.py @@ -42,7 +42,7 @@ async def test_cifs_mount( } mount: CIFSMount = Mount.from_dict(coresys, mount_data) - assert type(mount) == CIFSMount + assert isinstance(mount, CIFSMount) assert mount.name == "test" assert mount.type == MountType.CIFS assert mount.usage == MountUsage.MEDIA @@ -102,7 +102,7 @@ async def test_nfs_mount( } mount: NFSMount = Mount.from_dict(coresys, mount_data) - assert type(mount) == NFSMount + assert isinstance(mount, NFSMount) assert mount.name == "test" assert mount.type == MountType.NFS assert mount.usage == MountUsage.MEDIA