From d5c5a294902b80ac6d4d0e2c4386d398888ca084 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 3 Oct 2024 15:05:01 +0300 Subject: [PATCH] Check `python/uv/` folder with `mypy` (#7891) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It used to report: ``` ยป mypy python/uv/_build_backend.py:40: error: Incompatible types in assignment (expression has type "list[str]", variable has type "CompletedProcess[bytes]") [assignment] python/uv/_build_backend.py:41: error: Value of type "CompletedProcess[bytes]" is not indexable [index] python/uv/_build_backend.py:46: error: Value of type "CompletedProcess[bytes]" is not indexable [index] Found 3 errors in 1 file (checked 6 source files) ``` So, I had to fix this problem by renaming the `result` var. --- pyproject.toml | 5 ++++- python/uv/_build_backend.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 74b53112c4bb..5401bd03a533 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,10 @@ version_files = [ [tool.mypy] ignore_missing_imports = true -files = "crates/uv-python/*.py" +files = [ + "crates/uv-python/*.py", + "python/uv/*.py", +] [tool.uv] managed = false diff --git a/python/uv/_build_backend.py b/python/uv/_build_backend.py index a1284fe40b73..5ab4cb1ba3f4 100644 --- a/python/uv/_build_backend.py +++ b/python/uv/_build_backend.py @@ -37,13 +37,13 @@ def call(args: "list[str]", config_settings: "dict | None" = None) -> str: if result.returncode != 0: sys.exit(result.returncode) # If there was extra stdout, forward it (there should not be extra stdout) - result = result.stdout.decode("utf-8").strip().splitlines(keepends=True) - sys.stdout.writelines(result[:-1]) + stdout = result.stdout.decode("utf-8").strip().splitlines(keepends=True) + sys.stdout.writelines(stdout[:-1]) # Fail explicitly instead of an irrelevant stacktrace - if not result: + if not stdout: print("uv subprocess did not return a filename on stdout", file=sys.stderr) sys.exit(1) - return result[-1].strip() + return stdout[-1].strip() def build_sdist(sdist_directory: str, config_settings: "dict | None" = None):