Skip to content

Commit 3383e16

Browse files
thomas-manginclaude
andcommitted
refactor: Remove backward compat layer from UpdateCollection
- Remove auto-wrapping of bare NLRIs in UpdateCollection.__init__ - Change type signature to enforce list[RoutedNLRI] for announces - Update all 28 fuzz tests to use create_routed_nlri() helper - Withdraws continue to use bare NLRI (correct behavior) All callers now must explicitly use RoutedNLRI for announces. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c9eafc7 commit 3383e16

File tree

2 files changed

+88
-95
lines changed

2 files changed

+88
-95
lines changed

src/exabgp/bgp/message/update/collection.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,14 @@ class UpdateCollection(Message):
9999

100100
def __init__(
101101
self,
102-
announces: 'list[RoutedNLRI] | list[NLRI]',
102+
announces: list[RoutedNLRI],
103103
withdraws: list[NLRI],
104104
attributes: AttributeCollection,
105105
) -> None:
106106
# UpdateCollection is a composite container - NLRIs and Attributes are already packed-bytes-first
107107
# No single _packed representation exists because messages() can generate multiple
108108
# wire-format messages from one UpdateCollection due to size limits
109-
110-
# Backward compatibility: accept either list[RoutedNLRI] or list[NLRI]
111-
# If bare NLRIs are passed, wrap them with their nlri.nexthop
112-
# TODO: Remove this once all callers use RoutedNLRI
113-
if announces and not isinstance(announces[0], RoutedNLRI):
114-
# Legacy mode: wrap bare NLRIs
115-
self._announces: list[RoutedNLRI] = [
116-
RoutedNLRI(nlri, nlri.nexthop)
117-
for nlri in announces # type: ignore
118-
]
119-
else:
120-
self._announces = announces # type: ignore
109+
self._announces: list[RoutedNLRI] = announces
121110
self._withdraws: list[NLRI] = withdraws
122111
self._attributes: AttributeCollection = attributes
123112

0 commit comments

Comments
 (0)