From 7edd8dfe338888f90d8a39ba2d20d101d560661b Mon Sep 17 00:00:00 2001 From: jankesec <295349953+jankesec@users.noreply.github.com> Date: Tue, 1 Sep 2026 12:01:23 +0300 Subject: [PATCH] typing: allow Packet classes in Packet.fields_desc type hint Packet_metaclass explicitly supports and resolves references to Packet classes in fields_desc by inlining their fields_desc at class creation time. Update Packet.fields_desc type annotation from ClassVar[List[AnyField]] to ClassVar[List[Union[AnyField, Type[Packet]]]]. Fixes #5018 AI-Assisted: yes (Antigravity) --- scapy/packet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scapy/packet.py b/scapy/packet.py index 8afb483c94b..3cffdcb0142 100644 --- a/scapy/packet.py +++ b/scapy/packet.py @@ -105,7 +105,7 @@ class Packet( "process_information" ] name = None - fields_desc = [] # type: ClassVar[List[AnyField]] + fields_desc = [] # type: ClassVar[List[Union[AnyField, Type[Packet]]]] deprecated_fields = {} # type: Dict[str, Tuple[str, str]] overload_fields = {} # type: Dict[Type[Packet], Dict[str, Any]] payload_guess = [] # type: List[Tuple[Dict[str, Any], Type[Packet]]]