Skip to content

task: Remove node variable from client.filters() #469

@ogenstad

Description

@ogenstad

Component

Python SDK

Task Description

This is a follow-up task after #468.

Within client.filters() we are setting a node variable:

node = InfrahubNode(client=self, schema=schema, branch=branch)

The variable is sent into a batch task when we use parallell mode:

for page_number in range(1, total_pages + 1):
page_offset = (page_number - 1) * pagination_size
batch_process.add(task=process_page, node=node, page_offset=page_offset, page_number=page_number)
async for _, response in batch_process.execute():
nodes.extend(response[1]["nodes"])
related_nodes.extend(response[1]["related_nodes"])

However we ignore the node variable in the for loop so it's never used.

A bit further down in this function we then shadow the node variable name in two places as we use them as loop variables within a for-loop:

if populate_store:
for node in nodes:
if node.id:
self.store.set(node=node)
related_nodes = list(set(related_nodes))
for node in related_nodes:
if node.id:
self.store.set(node=node)

It would be cleaner to remove this node variable from the client.filters() methods (both sync and async), to avoid setting an unused variable and also to avoid confusion with the shadowing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions