Skip to content

Commit 2466530

Browse files
committed
Revent Packet, fix Enum annotation
1 parent 9015402 commit 2466530

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

scapy/arch/linux/rtnetlink.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def default_payload_class(self, payload: bytes) -> Type[Packet]:
394394

395395
class ifinfomsg(Packet):
396396
fields_desc = [
397-
ByteEnumField("ifi_family", 0, socket.AddressFamily), # type: ignore
397+
ByteEnumField("ifi_family", 0, socket.AddressFamily),
398398
ByteField("res", 0),
399399
Field("ifi_type", 0, fmt="=H"),
400400
Field("ifi_index", 0, fmt="=i"),
@@ -483,7 +483,7 @@ def default_payload_class(self, payload: bytes) -> Type[Packet]:
483483

484484
class ifaddrmsg(Packet):
485485
fields_desc = [
486-
ByteEnumField("ifa_family", 0, socket.AddressFamily), # type: ignore
486+
ByteEnumField("ifa_family", 0, socket.AddressFamily),
487487
ByteField("ifa_prefixlen", 0),
488488
FlagsField(
489489
"ifa_flags",
@@ -607,7 +607,7 @@ def default_payload_class(self, payload: bytes) -> Type[Packet]:
607607

608608
class rtmsg(Packet):
609609
fields_desc = [
610-
ByteEnumField("rtm_family", 0, socket.AddressFamily), # type: ignore
610+
ByteEnumField("rtm_family", 0, socket.AddressFamily),
611611
ByteField("rtm_dst_len", 0),
612612
ByteField("rtm_src_len", 0),
613613
ByteField("rtm_tos", 0),

scapy/base_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def __call__(cls,
463463
*args, # type: Any
464464
**kargs # type: Any
465465
):
466-
# type: (...) -> 'cls'
466+
# type: (...) -> 'Packet'
467467
if "dispatch_hook" in cls.__dict__:
468468
try:
469469
cls = cls.dispatch_hook(*args, **kargs)

scapy/fields.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,7 @@ class CharEnumField(EnumField[str]):
26472647
def __init__(self,
26482648
name, # type: str
26492649
default, # type: str
2650-
enum, # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2650+
enum, # type: Union[Dict[str, str], Dict[str, str], List[str], DADict[str, str], Type[Enum], Tuple[Callable[[str], str], Callable[[str], str]]] # noqa: E501
26512651
fmt="1s", # type: str
26522652
):
26532653
# type: (...) -> None
@@ -2674,7 +2674,7 @@ def __init__(self,
26742674
name, # type: str
26752675
default, # type: Optional[int]
26762676
size, # type: int
2677-
enum, # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2677+
enum, # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
26782678
**kwargs # type: Any
26792679
):
26802680
# type: (...) -> None
@@ -2700,7 +2700,7 @@ def __init__(self,
27002700
name, # type: str
27012701
default, # type: Optional[int]
27022702
length_from, # type: Callable[[Packet], int]
2703-
enum, # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2703+
enum, # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27042704
**kwargs, # type: Any
27052705
):
27062706
# type: (...) -> None
@@ -2725,7 +2725,7 @@ class ShortEnumField(EnumField[int]):
27252725
def __init__(self,
27262726
name, # type: str
27272727
default, # type: Optional[int]
2728-
enum, # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2728+
enum, # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27292729
):
27302730
# type: (...) -> None
27312731
super(ShortEnumField, self).__init__(name, default, enum, "H")
@@ -2735,7 +2735,7 @@ class LEShortEnumField(EnumField[int]):
27352735
def __init__(self,
27362736
name, # type: str
27372737
default, # type: Optional[int]
2738-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2738+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27392739
):
27402740
# type: (...) -> None
27412741
super(LEShortEnumField, self).__init__(name, default, enum, "<H")
@@ -2745,7 +2745,7 @@ class LongEnumField(EnumField[int]):
27452745
def __init__(self,
27462746
name, # type: str
27472747
default, # type: Optional[int]
2748-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2748+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27492749
):
27502750
# type: (...) -> None
27512751
super(LongEnumField, self).__init__(name, default, enum, "Q")
@@ -2755,7 +2755,7 @@ class LELongEnumField(EnumField[int]):
27552755
def __init__(self,
27562756
name, # type: str
27572757
default, # type: Optional[int]
2758-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2758+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27592759
):
27602760
# type: (...) -> None
27612761
super(LELongEnumField, self).__init__(name, default, enum, "<Q")
@@ -2765,7 +2765,7 @@ class ByteEnumField(EnumField[int]):
27652765
def __init__(self,
27662766
name, # type: str
27672767
default, # type: Optional[int]
2768-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2768+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27692769
):
27702770
# type: (...) -> None
27712771
super(ByteEnumField, self).__init__(name, default, enum, "B")
@@ -2791,7 +2791,7 @@ class IntEnumField(EnumField[int]):
27912791
def __init__(self,
27922792
name, # type: str
27932793
default, # type: Optional[int]
2794-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2794+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
27952795
):
27962796
# type: (...) -> None
27972797
super(IntEnumField, self).__init__(name, default, enum, "I")
@@ -2801,7 +2801,7 @@ class SignedIntEnumField(EnumField[int]):
28012801
def __init__(self,
28022802
name, # type: str
28032803
default, # type: Optional[int]
2804-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2804+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
28052805
):
28062806
# type: (...) -> None
28072807
super(SignedIntEnumField, self).__init__(name, default, enum, "i")
@@ -2811,7 +2811,7 @@ class LEIntEnumField(EnumField[int]):
28112811
def __init__(self,
28122812
name, # type: str
28132813
default, # type: Optional[int]
2814-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2814+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
28152815
):
28162816
# type: (...) -> None
28172817
super(LEIntEnumField, self).__init__(name, default, enum, "<I")
@@ -2829,7 +2829,7 @@ class LE3BytesEnumField(LEThreeBytesField, _EnumField[int]):
28292829
def __init__(self,
28302830
name, # type: str
28312831
default, # type: Optional[int]
2832-
enum # type: Union[Dict[I, str], Dict[str, I], List[str], DADict[I, str], Type[Enum], Tuple[Callable[[I], str], Callable[[str], I]]] # noqa: E501
2832+
enum # type: Union[Dict[int, str], Dict[str, int], List[str], DADict[int, str], Type[Enum], Tuple[Callable[[int], str], Callable[[str], int]]] # noqa: E501
28332833
):
28342834
# type: (...) -> None
28352835
_EnumField.__init__(self, name, default, enum)

0 commit comments

Comments
 (0)