mirror of https://github.com/secdev/scapy.git
Upgrade to mypy 0.790
This commit is contained in:
parent
c5284775fa
commit
575ae48105
|
@ -44,7 +44,7 @@ jobs:
|
|||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
python-version: 3.8
|
||||
- name: Install tox
|
||||
run: pip install tox
|
||||
- name: Run mypy
|
||||
|
|
|
@ -156,7 +156,7 @@ else:
|
|||
Set = _FakeType("Set", set) # type: ignore
|
||||
Tuple = _FakeType("Tuple")
|
||||
Type = _FakeType("Type", type)
|
||||
TypeVar = _FakeType("TypeVar")
|
||||
TypeVar = _FakeType("TypeVar") # type: ignore
|
||||
Union = _FakeType("Union")
|
||||
|
||||
class Sized(object): # type: ignore
|
||||
|
|
|
@ -28,6 +28,7 @@ from scapy.layers.l2 import CookedLinux
|
|||
from scapy.error import Scapy_Exception
|
||||
from scapy.plist import PacketList
|
||||
from scapy.supersocket import SuperSocket
|
||||
from scapy.utils import _ByteStream
|
||||
|
||||
__all__ = ["CAN", "SignalPacket", "SignalField", "LESignedSignalField",
|
||||
"LEUnsignedSignalField", "LEFloatSignalField", "BEFloatSignalField",
|
||||
|
@ -380,21 +381,20 @@ class CandumpReader:
|
|||
|
||||
@staticmethod
|
||||
def open(filename):
|
||||
# type: (Union[IO[Any], str]) -> Tuple[str, IO[Any]]
|
||||
# type: (Union[IO[bytes], str]) -> Tuple[str, _ByteStream]
|
||||
"""Open (if necessary) filename."""
|
||||
if isinstance(filename, six.string_types):
|
||||
filename = cast(str, filename)
|
||||
if isinstance(filename, str):
|
||||
try:
|
||||
fdesc = gzip.open(filename, "rb")
|
||||
fdesc = gzip.open(filename, "rb") # type: _ByteStream
|
||||
# try read to cause exception
|
||||
fdesc.read(1)
|
||||
fdesc.seek(0)
|
||||
except IOError:
|
||||
fdesc = open(filename, "rb")
|
||||
return filename, fdesc
|
||||
else:
|
||||
fdesc = cast(IO[Any], filename)
|
||||
filename = getattr(fdesc, "name", "No name")
|
||||
return cast(str, filename), fdesc
|
||||
name = getattr(filename, "name", "No name")
|
||||
return name, filename
|
||||
|
||||
def next(self):
|
||||
# type: () -> Packet
|
||||
|
@ -424,10 +424,10 @@ class CandumpReader:
|
|||
is_log_file_format = orb(line[0]) == orb(b"(")
|
||||
|
||||
if is_log_file_format:
|
||||
t, intf, f = line.split()
|
||||
t_b, intf, f = line.split()
|
||||
idn, data = f.split(b'#')
|
||||
le = None
|
||||
t = float(t[1:-1])
|
||||
t = float(t_b[1:-1]) # type: Optional[float]
|
||||
else:
|
||||
h, data = line.split(b']')
|
||||
intf, idn, le = h.split()
|
||||
|
|
|
@ -225,7 +225,7 @@ def list_contrib(name=None, # type: Optional[str]
|
|||
ret=False, # type: bool
|
||||
_debug=False # type: bool
|
||||
):
|
||||
# type: (...) -> Optional[List[Dict[str, Union[str, None]]]]
|
||||
# type: (...) -> Optional[List[Dict[str, str]]]
|
||||
"""Show the list of all existing contribs.
|
||||
|
||||
:param name: filter to search the contribs
|
||||
|
@ -244,7 +244,7 @@ def list_contrib(name=None, # type: Optional[str]
|
|||
name = "*.py"
|
||||
elif "*" not in name and "?" not in name and not name.endswith(".py"):
|
||||
name += ".py"
|
||||
results = [] # type: List[Dict[str, Union[str, None]]]
|
||||
results = [] # type: List[Dict[str, str]]
|
||||
dir_path = os.path.join(os.path.dirname(__file__), "contrib")
|
||||
if sys.version_info >= (3, 5):
|
||||
name = os.path.join(dir_path, "**", name)
|
||||
|
@ -258,7 +258,7 @@ def list_contrib(name=None, # type: Optional[str]
|
|||
continue
|
||||
if mod.endswith(".py"):
|
||||
mod = mod[:-3]
|
||||
desc = {"description": None, "status": None, "name": mod}
|
||||
desc = {"description": "", "status": "", "name": mod}
|
||||
with io.open(f, errors="replace") as fd:
|
||||
for line in fd:
|
||||
if line[0] != "#":
|
||||
|
|
Loading…
Reference in New Issue