Skip to content

Commit 0c7444b

Browse files
authored
Merge pull request #248 from lkollar/mypy
Add mypy to lint checks
2 parents 6514fbf + a044cdf commit 0c7444b

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

auditwheel/lddtree.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def load_ld_paths(root: str = '/', prefix: str = '') -> Dict[str, List[str]]:
183183
-------
184184
dict containing library paths to search
185185
"""
186-
ldpaths = {'conf': [], 'env': [], 'interp': []}
186+
ldpaths = {'conf': [], 'env': [], 'interp': []} # type: Dict
187187

188188
# Load up $LD_LIBRARY_PATH.
189189
env_ldpath = os.environ.get('LD_LIBRARY_PATH')
@@ -312,9 +312,12 @@ def lddtree(path: str,
312312
},
313313
}
314314
"""
315+
if not ldpaths:
316+
ldpaths = load_ld_paths().copy()
317+
315318
if _first:
316319
_all_libs = {}
317-
ldpaths = load_ld_paths().copy()
320+
318321
ret = {
319322
'interp': None,
320323
'path': path if display is None else display,

auditwheel/main_show.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import logging
22

3-
try:
4-
from collections.abc import OrderedDict
5-
except ImportError:
6-
from collections import OrderedDict
3+
from collections import OrderedDict
74

85
logger = logging.getLogger(__name__)
96

auditwheel/policy/external_references.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_req_external(libs: Set[str], whitelist: Set[str]):
5454
whitelist = set(p['lib_whitelist'])
5555
needed_external_libs = get_req_external(
5656
set(filter_libs(lddtree['needed'], whitelist)),
57-
whitelist) # type: List[str]
57+
whitelist)
5858

5959
pol_ext_deps = {}
6060
for lib in needed_external_libs:

auditwheel/repair.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from collections import OrderedDict
99
from os.path import exists, basename, abspath, isabs, dirname
1010
from os.path import join as pjoin
11-
from typing import Dict, Optional
11+
from typing import Dict, Optional, Tuple
1212

1313
from auditwheel.patcher import ElfPatcher
1414
from .elfutils import elf_read_rpaths, elf_read_dt_needed, is_subdir
@@ -34,9 +34,9 @@ def repair_wheel(wheel_path: str, abi: str, lib_sdir: str, out_dir: str,
3434

3535
# Do not repair a pure wheel, i.e. has no external refs
3636
if not external_refs_by_fn:
37-
return
37+
return None
3838

39-
soname_map = {} # type: Dict[str, str]
39+
soname_map = {} # type: Dict[str, Tuple[str, str]]
4040
if not isabs(out_dir):
4141
out_dir = abspath(out_dir)
4242

@@ -45,7 +45,12 @@ def repair_wheel(wheel_path: str, abi: str, lib_sdir: str, out_dir: str,
4545
with InWheelCtx(wheel_path) as ctx:
4646
ctx.out_wheel = pjoin(out_dir, wheel_fname)
4747

48-
dest_dir = WHEEL_INFO_RE(wheel_fname).group('name') + lib_sdir
48+
match = WHEEL_INFO_RE(wheel_fname)
49+
if not match:
50+
raise ValueError("Failed to parse wheel file name: %s",
51+
wheel_fname)
52+
53+
dest_dir = match.group('name') + lib_sdir
4954

5055
if not exists(dest_dir):
5156
os.mkdir(dest_dir)

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ flake8
66
pretend
77
docker
88
pyelftools
9+
mypy

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ commands = pytest --doctest-modules auditwheel tests []
1010

1111
[testenv:lint]
1212
commands = flake8 auditwheel
13+
mypy auditwheel
1314

1415
[testenv:cov]
1516
commands = python -m pytest tests/unit --cov=auditwheel --cov-report=term-missing

0 commit comments

Comments
 (0)