Skip to content

Commit 55ae968

Browse files
committed
Improve typing slightly
1 parent 24dae9d commit 55ae968

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = [ "setuptools>=62.0.0" ]
2+
requires = [ "setuptools>=77.0.0" ]
33
build-backend = "setuptools.build_meta"
44

55
[project]

scapy/layers/l2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,14 +895,14 @@ def arpcachepoison(
895895

896896
@conf.commands.register
897897
def arp_mitm(
898-
ip1, # type: str
899-
ip2, # type: str
898+
ip1: str,
899+
ip2: str,
900900
mac1=None, # type: Optional[Union[str, List[str]]]
901901
mac2=None, # type: Optional[Union[str, List[str]]]
902-
broadcast=False, # type: bool
903-
target_mac=None, # type: Optional[str]
904-
iface=None, # type: Optional[_GlobInterfaceType]
905-
inter=3, # type: int
902+
broadcast: bool = False,
903+
target_mac: Optional[str] = None,
904+
iface: Optional[_GlobInterfaceType] = None,
905+
inter: int = 3,
906906
):
907907
# type: (...) -> None
908908
r"""ARP MitM: poison 2 target's ARP cache

scapy/layers/smbclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ def __init__(
11261126
guest: bool = False,
11271127
kerberos: bool = True,
11281128
kerberos_required: bool = False,
1129-
HashNt: str = None,
1129+
HashNt: bytes = None,
11301130
port: int = 445,
11311131
timeout: int = 2,
11321132
debug: int = 0,

scapy/utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,13 +3900,26 @@ def AutoArgparse(func: DecoratorCallable) -> None:
39003900
continue
39013901
parname = param.name
39023902
paramkwargs = {}
3903-
if param.annotation is bool:
3903+
paramtype = param.annotation
3904+
# Process types we don't know
3905+
if paramtype not in [bool, str, int, float]:
3906+
try:
3907+
if paramtype.__origin__ is Union:
3908+
# Handles Optional[] and Union[]
3909+
paramtype = next(
3910+
x for x in paramtype.__args__
3911+
if x in [bool, str, int, float]
3912+
)
3913+
except Exception:
3914+
pass
3915+
# Process the types we know
3916+
if paramtype is bool:
39043917
if param.default is True:
39053918
parname = "no-" + parname
39063919
paramkwargs["action"] = "store_false"
39073920
else:
39083921
paramkwargs["action"] = "store_true"
3909-
elif param.annotation in [str, int, float]:
3922+
elif paramtype in [str, int, float]:
39103923
paramkwargs["type"] = param.annotation
39113924
else:
39123925
continue

0 commit comments

Comments
 (0)