Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infrahub_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def clone(self, branch: str | None = None) -> Config:
"log": self.log,
}
covered_keys = list(config.keys())
for field in Config.model_fields.keys():
for field in Config.model_fields:
if field not in covered_keys:
config[field] = deepcopy(getattr(self, field))

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ async def generate_return_types(

generate_result_types(directory=directory, package=package_generator, fragment=module_fragment)

for file_name in package_generator._result_types_files.keys():
for file_name in package_generator._result_types_files:
console.print(f"[green]Generated {file_name} in {directory}")
2 changes: 1 addition & 1 deletion infrahub_sdk/node/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, name: str, schema: AttributeSchemaAPI, data: Any | dict) -> N
self.name = name
self._schema = schema

if not isinstance(data, dict) or "value" not in data.keys():
if not isinstance(data, dict) or "value" not in data:
data = {"value": data}

self._properties_flag = PROPERTIES_FLAG
Expand Down
8 changes: 4 additions & 4 deletions infrahub_sdk/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ def _generate_input_data( # noqa: C901
def _strip_unmodified_dict(data: dict, original_data: dict, variables: dict, item: str) -> None:
data_item = data.get(item)
if item in original_data and isinstance(original_data[item], dict) and isinstance(data_item, dict):
for item_key in original_data[item].keys():
for item_key in original_data[item]:
for property_name in PROPERTIES_OBJECT:
if item_key == property_name and isinstance(original_data[item][property_name], dict):
if original_data[item][property_name].get("id"):
original_data[item][property_name] = original_data[item][property_name]["id"]
if item_key in data[item].keys():
if item_key in data[item]:
if item_key == "id" and len(data[item].keys()) > 1:
# Related nodes typically require an ID. So the ID is only
# removed if it's the last key in the current context
Expand Down Expand Up @@ -335,8 +335,8 @@ def _strip_unmodified(self, data: dict, variables: dict) -> tuple[dict, dict]:
elif isinstance(relationship_property, RelationshipManagerBase) and not relationship_property.has_update:
data.pop(relationship)

for item in original_data.keys():
if item in data.keys():
for item in original_data:
if item in data:
if data[item] == original_data[item]:
if attr := getattr(self, item, None): # this should never be None, just a safety default value
if not isinstance(attr, Attribute) or not attr.value_has_been_mutated:
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def process_nodes(self, data: dict) -> None:
await self._init_client.schema.all(branch=self.branch_name)

for kind in data:
if kind in self._init_client.schema.cache[self.branch_name].nodes.keys():
if kind in self._init_client.schema.cache[self.branch_name].nodes:
for result in data[kind].get("edges", []):
node = await self.infrahub_node.from_graphql(
client=self._init_client, branch=self.branch_name, data=result
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def validate(self, data: dict[str, Any]) -> None:
SchemaRoot(**data)

def validate_data_against_schema(self, schema: MainSchemaTypesAPI, data: dict) -> None:
for key in data.keys():
for key in data:
if key not in schema.relationship_names + schema.attribute_names:
identifier = f"{schema.kind}"
raise ValidationError(
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/spec/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def validate_object(

# First validate if all mandatory fields are present
for element in schema.mandatory_input_names:
if not any([element in data.keys(), element in context.keys()]):
if not any([element in data, element in context]):
errors.append(ObjectValidationError(position=position + [element], message=f"{element} is mandatory"))

# Validate if all attributes are valid
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/transfer/importer/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def remove_and_store_optional_relationships(self) -> None:
relationship_schema
)

for relationship_name in self.optional_relationships_schemas_by_node_kind[node_kind].keys():
for relationship_name in self.optional_relationships_schemas_by_node_kind[node_kind]:
relationship_value = getattr(node, relationship_name)
if isinstance(relationship_value, RelationshipManager):
if relationship_value.peer_ids:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ ignore = [
"SIM110", # Use `return any(getattr(item, resource_field) == resource_id for item in getattr(self, RESOURCE_MAP[resource_type]))` instead of `for` loop
"SIM114", # Combine `if` branches using logical `or` operator
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
"SIM118", # Use `key in dict` instead of `key in dict.keys)
"TC003", # Move standard library import `collections.abc.Iterable` into a type-checking block
"UP031", # Use format specifiers instead of percent format
"UP045", # Use `X | None` for type annotations
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_infrahub_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ async def test_branch_delete(self, client: InfrahubClient, base_dataset) -> None
pre_delete = await client.branch.all()
await client.branch.delete(async_branch)
post_delete = await client.branch.all()
assert async_branch in pre_delete.keys()
assert async_branch not in post_delete.keys()
assert async_branch in pre_delete
assert async_branch not in post_delete

async def test_get_all(self, client: InfrahubClient, base_dataset) -> None:
nodes = await client.all(kind=TESTING_CAT)
Expand Down