From c6b6b64d7d19a2df926dbff467cae73cd946cf70 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 21 Feb 2023 00:32:02 +0000 Subject: [PATCH 1/2] Enable some more mypy lints when checking our own code --- tests/typecheck_typeshed.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/typecheck_typeshed.py b/tests/typecheck_typeshed.py index 441e5b2732de..dc9c2a3cfde0 100644 --- a/tests/typecheck_typeshed.py +++ b/tests/typecheck_typeshed.py @@ -57,15 +57,19 @@ def run_mypy_as_subprocess(directory: str, platform: str, version: str) -> Retur "--no-error-summary", "--enable-error-code", "ignore-without-code", + "--enable-error-code", + "possibly-undefined", + "--enable-error-code", + "redundant-expr", ] if directory == "tests" and platform == "win32": command.extend(["--exclude", "tests/pytype_test.py"]) - result = subprocess.run(command, capture_output=True) + result = subprocess.run(command, capture_output=True, text=True) stdout, stderr = result.stdout, result.stderr if stderr: - print_error(stderr.decode()) + print_error(stderr) if stdout: - print_error(stdout.decode()) + print_error(stdout) return result.returncode From c21424e175af121920716e796e1ad70c8960a273 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 21 Feb 2023 00:46:38 +0000 Subject: [PATCH 2/2] Address review --- tests/typecheck_typeshed.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/typecheck_typeshed.py b/tests/typecheck_typeshed.py index dc9c2a3cfde0..4a97c342d45b 100644 --- a/tests/typecheck_typeshed.py +++ b/tests/typecheck_typeshed.py @@ -65,11 +65,10 @@ def run_mypy_as_subprocess(directory: str, platform: str, version: str) -> Retur if directory == "tests" and platform == "win32": command.extend(["--exclude", "tests/pytype_test.py"]) result = subprocess.run(command, capture_output=True, text=True) - stdout, stderr = result.stdout, result.stderr - if stderr: - print_error(stderr) - if stdout: - print_error(stdout) + if result.stderr: + print_error(result.stderr) + if result.stdout: + print_error(result.stdout) return result.returncode