diff --git a/mypy/build.py b/mypy/build.py index ff9b48d2d7b4..4745610d7920 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2140,6 +2140,7 @@ def parse_file(self, *, temporary: bool = False) -> None: # other systems, but os.strerror(ioerr.errno) does not, so we use that. # (We want the error messages to be platform-independent so that the # tests have predictable output.) + assert ioerr.errno is not None raise CompileError( [ "mypy: can't read file '{}': {}".format( diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py index 9b15f2aff90e..bc11c1304776 100644 --- a/mypy/modulefinder.py +++ b/mypy/modulefinder.py @@ -777,6 +777,7 @@ def get_search_dirs(python_executable: str | None) -> tuple[list[str], list[str] print(err.stdout) raise except OSError as err: + assert err.errno is not None reason = os.strerror(err.errno) raise CompileError( [f"mypy: Invalid python executable '{python_executable}': {reason}"]