From 03d728e281aa23848139241a58d8564273989a5e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Apr 2024 10:23:19 +1100 Subject: [PATCH] Cleanup: improve type checking in project_source_info.py Since the type hints were added it seems mypy has been improved making it possible to remove the workarounds. --- build_files/cmake/project_source_info.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build_files/cmake/project_source_info.py b/build_files/cmake/project_source_info.py index ccec3f5e6d8..fa085cc9210 100644 --- a/build_files/cmake/project_source_info.py +++ b/build_files/cmake/project_source_info.py @@ -24,12 +24,12 @@ from typing import ( Any, Callable, Generator, + IO, List, Optional, Sequence, Tuple, Union, - cast, ) import shlex @@ -120,12 +120,13 @@ def makefile_log() -> List[str]: time.sleep(1) # We know this is always true based on the input arguments to `Popen`. - stdout: IO[bytes] = process.stdout # type: ignore + assert process.stdout is not None + stdout: IO[bytes] = process.stdout out = stdout.read() stdout.close() print("done!", len(out), "bytes") - return cast(List[str], out.decode("utf-8", errors="ignore").split("\n")) + return out.decode("utf-8", errors="ignore").split("\n") def build_info( @@ -211,9 +212,10 @@ def build_defines_as_source() -> str: ) # We know this is always true based on the input arguments to `Popen`. - stdout: IO[bytes] = process.stdout # type: ignore + assert process.stdout is not None + stdout: IO[bytes] = process.stdout - return cast(str, stdout.read().strip().decode('ascii')) + return stdout.read().strip().decode('ascii') def build_defines_as_args() -> List[str]: