-
Couldn't load subscription status.
- Fork 6
Description
Component
Python SDK
Task Description
This is a follow-up task after #468.
Within client.filters() we are setting a node variable:
infrahub-sdk-python/infrahub_sdk/client.py
Line 787 in ec3627f
| node = InfrahubNode(client=self, schema=schema, branch=branch) |
The variable is sent into a batch task when we use parallell mode:
infrahub-sdk-python/infrahub_sdk/client.py
Lines 831 to 837 in ec3627f
| 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:
infrahub-sdk-python/infrahub_sdk/client.py
Lines 864 to 871 in ec3627f
| 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.