aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2020-05-01 13:38:38 -0700
committerDan Albert <danalbert@google.com>2020-05-01 13:38:38 -0700
commit91e432956d2c1a1d33e1ca067f7ed61c14753896 (patch)
tree68c4af3015c2628419de928e66e1520f9e6b9f78
parent684fea0e245aaa0bb5769a7b818a20e2eae78b83 (diff)
downloadndk-91e432956d2c1a1d33e1ca067f7ed61c14753896.tar.gz
Clean up mypy issues.
Test: mypy ndk Bug: None Change-Id: I8e65d4edfa7c4af7033cbfa09958b67d7cb52177
-rwxr-xr-xndk/checkbuild.py4
-rwxr-xr-xndk/run_tests.py20
-rw-r--r--ndk/test/devices.py9
-rw-r--r--ndk/test/types.py6
4 files changed, 22 insertions, 17 deletions
diff --git a/ndk/checkbuild.py b/ndk/checkbuild.py
index d35bc6b22..7457d8882 100755
--- a/ndk/checkbuild.py
+++ b/ndk/checkbuild.py
@@ -835,7 +835,7 @@ class Libcxx(ndk.builds.Module):
name = 'libc++'
src = Path(ndk.paths.android_path('toolchain/llvm-project/libcxx'))
path = 'sources/cxx-stl/llvm-libc++'
- notice = src / 'LICENSE.TXT'
+ notice = str(src / 'LICENSE.TXT')
notice_group = ndk.builds.NoticeGroup.TOOLCHAIN
arch_specific = True
deps = {
@@ -1424,7 +1424,7 @@ class Gdb(ndk.builds.Module):
# Install libc++.
clang_path = ndk.toolchains.ClangToolchain.path_for_host(self.host)
- libcxx_files = {
+ libcxx_files: Dict[ndk.hosts.Host, List[str]] = {
ndk.hosts.Host.Darwin: ['libc++abi.1.dylib', 'libc++.1.dylib'],
ndk.hosts.Host.Linux: ['libc++abi.so.1', 'libc++.so.1'],
ndk.hosts.Host.Windows64: [],
diff --git a/ndk/run_tests.py b/ndk/run_tests.py
index cb622d737..834cd0857 100755
--- a/ndk/run_tests.py
+++ b/ndk/run_tests.py
@@ -655,16 +655,16 @@ def parse_args() -> argparse.Namespace:
# The type ignore is needed because realpath is an overloaded function, and
# mypy is bad at those (it doesn't satisfy Callable[[str], AnyStr]).
- config_options.add_argument( # type: ignore
+ config_options.add_argument(
'--config',
- type=os.path.realpath,
+ type=os.path.realpath, # type: ignore
default='qa_config.json',
help='Path to the config file describing the test run.')
build_options = parser.add_argument_group('Build Options')
- build_options.add_argument( # type: ignore
+ build_options.add_argument(
'--build-report',
- type=os.path.realpath,
+ type=os.path.realpath, # type: ignore
help='Write the build report to the given path.')
build_exclusive_group = build_options.add_mutually_exclusive_group()
@@ -697,20 +697,20 @@ def parse_args() -> argparse.Namespace:
'-v', '--verbose', action='count', default=0,
help='Increase log level. Defaults to logging.WARNING.')
- parser.add_argument( # type: ignore
+ parser.add_argument(
'--ndk',
- type=os.path.realpath,
+ type=os.path.realpath, # type: ignore
default=ndk.paths.get_install_path(),
help='NDK to validate. Defaults to ../out/android-ndk-$RELEASE.')
- parser.add_argument( # type: ignore
+ parser.add_argument(
'--test-src',
- type=os.path.realpath,
+ type=os.path.realpath, # type: ignore
help='Path to test source directory. Defaults to ./tests.')
- parser.add_argument( # type: ignore
+ parser.add_argument(
'test_dir',
metavar='TEST_DIR',
- type=os.path.realpath,
+ type=os.path.realpath, # type: ignore
nargs='?',
default=ndk.paths.path_in_out('tests'),
help='Directory containing built tests.')
diff --git a/ndk/test/devices.py b/ndk/test/devices.py
index 96381efcf..83855e184 100644
--- a/ndk/test/devices.py
+++ b/ndk/test/devices.py
@@ -327,15 +327,16 @@ def get_all_attached_devices(workqueue: WorkQueue) -> List[Device]:
# We could get the device name from `adb devices -l`, but we need to
# getprop to find other details anyway, and older devices don't report
# their names properly (nakasi on android-16, for example).
- p = subprocess.Popen(['adb', 'devices'], stdout=subprocess.PIPE)
- out, _ = p.communicate()
- out = out.decode('utf-8')
+ p = subprocess.run(['adb', 'devices'],
+ check=True,
+ stdout=subprocess.PIPE,
+ encoding='utf-8')
if p.returncode != 0:
raise RuntimeError('Failed to get list of devices from adb.')
# The first line of `adb devices` just says "List of attached devices", so
# skip that.
- for line in out.split('\n')[1:]:
+ for line in p.stdout.split('\n')[1:]:
if not line.strip():
continue
diff --git a/ndk/test/types.py b/ndk/test/types.py
index bb893c3a7..8a23505c3 100644
--- a/ndk/test/types.py
+++ b/ndk/test/types.py
@@ -440,10 +440,14 @@ def get_xunit_reports(xunit_file: Path, test_base_dir: str,
reports: List[Test] = []
for test_case in cases:
mangled_test_dir = test_case.get('classname')
+ assert mangled_test_dir is not None
+
+ case_name = test_case.get('name')
+ assert case_name is not None
# The classname is the path from the root of the libc++ test directory
# to the directory containing the test (prefixed with 'libc++.')...
- mangled_path = '/'.join([mangled_test_dir, test_case.get('name')])
+ mangled_path = '/'.join([mangled_test_dir, case_name])
# ... that has had '.' in its path replaced with '_' because xunit.
test_matches = find_original_libcxx_test(mangled_path)