mirror of
https://github.com/jtesta/ssh-audit.git
synced 2024-11-16 13:35:39 +01:00
Upgrade to Mypy 0.501 and fix issues. Add requirements.txt.
This commit is contained in:
parent
94a74e9cfd
commit
65ef250aae
18
ssh-audit.py
18
ssh-audit.py
@ -39,7 +39,7 @@ else: # pragma: nocover
|
||||
binary_type = str
|
||||
try: # pragma: nocover
|
||||
# pylint: disable=unused-import
|
||||
from typing import List, Set, Sequence, Tuple, Iterable
|
||||
from typing import Dict, List, Set, Sequence, Tuple, Iterable
|
||||
from typing import Callable, Optional, Union, Any
|
||||
except ImportError: # pragma: nocover
|
||||
pass
|
||||
@ -713,7 +713,8 @@ class ReadBuf(object):
|
||||
|
||||
def read_byte(self):
|
||||
# type: () -> int
|
||||
return struct.unpack('B', self.read(1))[0]
|
||||
v = struct.unpack('B', self.read(1))[0] # type: int
|
||||
return v
|
||||
|
||||
def read_bool(self):
|
||||
# type: () -> bool
|
||||
@ -721,7 +722,8 @@ class ReadBuf(object):
|
||||
|
||||
def read_int(self):
|
||||
# type: () -> int
|
||||
return struct.unpack('>I', self.read(4))[0]
|
||||
v = struct.unpack('>I', self.read(4))[0] # type: int
|
||||
return v
|
||||
|
||||
def read_list(self):
|
||||
# type: () -> List[text_type]
|
||||
@ -1268,8 +1270,10 @@ class SSH(object): # pylint: disable=too-few-public-methods
|
||||
@property
|
||||
def maxlen(self):
|
||||
# type: () -> int
|
||||
ml, maxlen = lambda l: max(len(i) for i in l), 0
|
||||
# type: Callable[[Sequence[text_type]], int], int
|
||||
maxlen = 0
|
||||
def ml(items):
|
||||
# type: (Sequence[text_type]) -> int
|
||||
return max(len(i) for i in items)
|
||||
if self.ssh1kex is not None:
|
||||
maxlen = max(ml(self.ssh1kex.supported_ciphers),
|
||||
ml(self.ssh1kex.supported_authentications),
|
||||
@ -1536,8 +1540,8 @@ class SSH(object): # pylint: disable=too-few-public-methods
|
||||
ipvo_len = len(ipvo)
|
||||
prefer_ipvo = ipvo_len > 0
|
||||
prefer_ipv4 = prefer_ipvo and ipvo[0] == 4
|
||||
if len(ipvo) == 1:
|
||||
family = {4: socket.AF_INET, 6: socket.AF_INET6}.get(ipvo[0])
|
||||
if ipvo_len == 1:
|
||||
family = socket.AF_INET if ipvo[0] == 4 else socket.AF_INET6
|
||||
else:
|
||||
family = socket.AF_UNSPEC
|
||||
try:
|
||||
|
@ -7,4 +7,9 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
_htmldir="${_cdir}/../html/mypy-py2"
|
||||
mkdir -p "${_htmldir}"
|
||||
env MYPYPATH="${_cdir}/stubs/" mypy --python-version 2.7 --strict-optional --config-file "${_cdir}/mypy.ini" --html-report "${_htmldir}" "${_cdir}/../ssh-audit.py"
|
||||
env MYPYPATH="${_cdir}/stubs/" mypy \
|
||||
--python-version 2.7 \
|
||||
--no-warn-incomplete-stub \
|
||||
--show-error-context \
|
||||
--config-file "${_cdir}/mypy.ini" \
|
||||
--html-report "${_htmldir}" "${_cdir}/../ssh-audit.py"
|
||||
|
@ -7,4 +7,8 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
_htmldir="${_cdir}/../html/mypy-py3"
|
||||
mkdir -p "${_htmldir}"
|
||||
env MYPYPATH="${_cdir}/stubs/" mypy --python-version 3.5 --strict-optional --config-file "${_cdir}/mypy.ini" --html-report "${_htmldir}" "${_cdir}/../ssh-audit.py"
|
||||
env MYPYPATH="${_cdir}/stubs/" mypy \
|
||||
--python-version 3.5 \
|
||||
--show-error-context \
|
||||
--config-file "${_cdir}/mypy.ini" \
|
||||
--html-report "${_htmldir}" "${_cdir}/../ssh-audit.py"
|
||||
|
@ -4,6 +4,10 @@ follow_imports = error
|
||||
disallow_untyped_calls = True
|
||||
disallow_untyped_defs = True
|
||||
check_untyped_defs = True
|
||||
disallow-subclassing-any = True
|
||||
warn-incomplete-stub = True
|
||||
warn-redundant-casts = True
|
||||
disallow_subclassing_any = True
|
||||
warn_incomplete_stub = True
|
||||
warn_redundant_casts = True
|
||||
warn_return_any = True
|
||||
warn_unused_ignores = True
|
||||
strict_optional = True
|
||||
#strict_boolean = False
|
||||
|
5
test/requirements-py2.txt
Normal file
5
test/requirements-py2.txt
Normal file
@ -0,0 +1,5 @@
|
||||
pytest==3.0.7
|
||||
pytest-cov==2.4.0
|
||||
lxml==3.7.3
|
||||
colorama==0.3.7
|
||||
prospector==0.12.4
|
6
test/requirements-py3.txt
Normal file
6
test/requirements-py3.txt
Normal file
@ -0,0 +1,6 @@
|
||||
pytest==3.0.7
|
||||
pytest-cov==2.4.0
|
||||
mypy==0.501
|
||||
lxml==3.7.3
|
||||
colorama==0.3.7
|
||||
prospector==0.12.4
|
Loading…
Reference in New Issue
Block a user