Skip to content
Open
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
4 changes: 2 additions & 2 deletions linode_api4/groups/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ def ip_addresses_assign(self, assignments, region):
:param assignments: Any number of assignments to make. See
:any:`IPAddress.to` for details on how to construct
assignments.
Comment on lines 452 to 454
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring still says "Any number of assignments to make" but the method now takes a single list of assignment objects. Please update the wording to reflect the actual expected argument shape to avoid confusing API consumers.

Suggested change
:param assignments: Any number of assignments to make. See
:any:`IPAddress.to` for details on how to construct
assignments.
:param assignments: A list of assignment objects to make. See
:any:`IPAddress.to` for details on how to construct
each assignment.

Copilot uses AI. Check for mistakes.
:type assignments: dct
:type assignments: list
"""

for a in assignments["assignments"]:
for a in assignments:
if not "address" in a or not "linode_id" in a:
Comment on lines +458 to 459
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing ip_addresses_assign to accept a bare list is a breaking change for any callers that were previously passing {"assignments": [...]}. Consider supporting both shapes for backward compatibility (e.g., if assignments is a dict with an assignments key, unwrap it) or at least raise a clearer error when a dict is provided (current loop will iterate dict keys and raise a generic Invalid assignment).

Suggested change
for a in assignments:
if not "address" in a or not "linode_id" in a:
if isinstance(assignments, dict):
if "assignments" in assignments:
assignments = assignments["assignments"]
else:
raise ValueError(
"Invalid assignments payload: expected a list of assignments "
"or a dict containing an 'assignments' key, got {}".format(
assignments
)
)
if not isinstance(assignments, list):
raise ValueError(
"Invalid assignments payload: expected a list of assignments, got {}".format(
type(assignments).__name__
)
)
for a in assignments:
if not isinstance(a, dict) or "address" not in a or "linode_id" not in a:

Copilot uses AI. Check for mistakes.
raise ValueError("Invalid assignment: {}".format(a))

Expand Down
4 changes: 2 additions & 2 deletions test/unit/linode_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,13 +1407,13 @@ def test_ip_addresses_assign(self):

with self.mock_post({}) as m:
self.client.networking.ip_addresses_assign(
{"assignments": [{"address": "192.0.2.1", "linode_id": 123}]},
[{"address": "192.0.2.1", "linode_id": 123}],
"us-east",
)
self.assertEqual(m.call_url, "/networking/ips/assign")
self.assertEqual(
m.call_data["assignments"],
{"assignments": [{"address": "192.0.2.1", "linode_id": 123}]},
[{"address": "192.0.2.1", "linode_id": 123}],
)
self.assertEqual(m.call_data["region"], "us-east")

Expand Down
Loading