From e1b7805aef25569310d2a1dc1fde69a53eb99d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 8 Jul 2024 16:30:15 +0200 Subject: [PATCH] fix new linter issues --- pkgs/clan-cli/clan_cli/config/__init__.py | 4 ++-- pkgs/clan-cli/tests/test_config.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/config/__init__.py b/pkgs/clan-cli/clan_cli/config/__init__.py index d1a7ce51b..1085bc314 100644 --- a/pkgs/clan-cli/clan_cli/config/__init__.py +++ b/pkgs/clan-cli/clan_cli/config/__init__.py @@ -81,11 +81,11 @@ def cast(value: Any, input_type: Any, opt_description: str) -> Any: else: raise ClanError(f"Invalid value {value} for boolean") # handle lists - elif get_origin(input_type) == list: + elif get_origin(input_type) is list: subtype = input_type.__args__[0] return [cast([x], subtype, opt_description) for x in value] # handle dicts - elif get_origin(input_type) == dict: + elif get_origin(input_type) is dict: if not isinstance(value, dict): raise ClanError( f"Cannot set {opt_description} directly. Specify a suboption like {opt_description}." diff --git a/pkgs/clan-cli/tests/test_config.py b/pkgs/clan-cli/tests/test_config.py index 508f361ae..64424d35f 100644 --- a/pkgs/clan-cli/tests/test_config.py +++ b/pkgs/clan-cli/tests/test_config.py @@ -108,7 +108,7 @@ def test_type_from_schema_path_simple() -> None: schema = dict( type="boolean", ) - assert parsing.type_from_schema_path(schema, []) == bool + assert parsing.type_from_schema_path(schema, []) is bool def test_type_from_schema_path_nested() -> None: @@ -125,8 +125,8 @@ def test_type_from_schema_path_nested() -> None: age=dict(type="integer"), ), ) - assert parsing.type_from_schema_path(schema, ["age"]) == int - assert parsing.type_from_schema_path(schema, ["name", "first"]) == str + assert parsing.type_from_schema_path(schema, ["age"]) is int + assert parsing.type_from_schema_path(schema, ["name", "first"]) is str def test_type_from_schema_path_dynamic_attrs() -> None: @@ -140,16 +140,16 @@ def test_type_from_schema_path_dynamic_attrs() -> None: ), ), ) - assert parsing.type_from_schema_path(schema, ["age"]) == int - assert parsing.type_from_schema_path(schema, ["users", "foo"]) == str + assert parsing.type_from_schema_path(schema, ["age"]) is int + assert parsing.type_from_schema_path(schema, ["users", "foo"]) is str def test_map_type() -> None: with pytest.raises(ClanError): config.map_type("foo") - assert config.map_type("string") == str - assert config.map_type("integer") == int - assert config.map_type("boolean") == bool + assert config.map_type("string") is str + assert config.map_type("integer") is int + assert config.map_type("boolean") is bool assert config.map_type("attribute set of string") == dict[str, str] assert config.map_type("attribute set of integer") == dict[str, int] assert config.map_type("null or string") == str | None