From 6190d369da03581e5561e1431c653a8c8592388e Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Mon, 13 May 2024 08:44:01 -0400 Subject: [PATCH] fix: dedup ips before checking length --- .pre-commit-config.yaml | 1 - src/gvm_sync_targets/cli/__init__.py | 4 ++-- tests/gvm_sync_targets/models/auth_response_test.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47ad795..ba1747a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,6 @@ repos: rev: 7c0bc1591103b1f089aab9810fc2a201ccb0552b - hooks: - entry: hatch run python3 -m mypy - exclude: tests/.* id: mypy language: system name: mypy diff --git a/src/gvm_sync_targets/cli/__init__.py b/src/gvm_sync_targets/cli/__init__.py index 191bcfd..fc7f5ee 100644 --- a/src/gvm_sync_targets/cli/__init__.py +++ b/src/gvm_sync_targets/cli/__init__.py @@ -47,11 +47,11 @@ def gvm_sync_targets( to_remove: list[str] = [] for host in existing_hosts.assets: - ips = [ + ips = { identifier.value for identifier in host.identifiers.identifiers if identifier.name == "ip" - ] + } if len(ips) > 1: raise ValueError(f"Multiple IPs?: {ips}") diff --git a/tests/gvm_sync_targets/models/auth_response_test.py b/tests/gvm_sync_targets/models/auth_response_test.py index 793533c..090e7c6 100644 --- a/tests/gvm_sync_targets/models/auth_response_test.py +++ b/tests/gvm_sync_targets/models/auth_response_test.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -from gvm_sync_targets.models import AuthenticateResponse +from gvm_sync_targets.models.auth_response import AuthenticateResponse data = """ @@ -12,7 +12,7 @@ """ -def test_auth_response(): +def test_auth_response() -> None: model = AuthenticateResponse.from_xml(data) assert model.role == "Admin" assert model.timezone == "UTC"