From d2a9e5a712a651221ae76bcc5b8b1f239dd183a1 Mon Sep 17 00:00:00 2001 From: Rahix Date: Thu, 1 Aug 2024 23:27:20 +0200 Subject: [PATCH] amend! machine.linux: Fix a mypy error machine.linux: Fix a mypy error Mypy was complaining that tbot/machine/linux/build.py:65: error: Argument 2 to "exec0" of "LinuxShell" has incompatible type "Path[H@__init__]"; expected "Union[str, Special[H@enable], Path[H@enable]]" Tweak the code so mypy correctly understands the relationship between types. --- tbot/machine/linux/build.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tbot/machine/linux/build.py b/tbot/machine/linux/build.py index 2abd0730..bba4ec68 100644 --- a/tbot/machine/linux/build.py +++ b/tbot/machine/linux/build.py @@ -21,14 +21,11 @@ from . import linux_shell, path -H = typing.TypeVar("H", bound="Builder") - - -class Toolchain(abc.ABC, typing.Generic[H]): +class Toolchain(abc.ABC): """Generic toolchain type.""" @abc.abstractmethod - def enable(self, host: H) -> None: + def enable(self, host: "Builder") -> None: """Enable this toolchain on the given ``host``.""" pass @@ -52,7 +49,7 @@ def toolchains(self): } """ - def __init__(self, path: path.Path[H]) -> None: + def __init__(self, path: "path.Path[Builder]") -> None: """ Create a new EnvScriptToolchain. @@ -60,7 +57,7 @@ def __init__(self, path: path.Path[H]) -> None: """ self.env_script = path - def enable(self, host: H) -> None: + def enable(self, host: "Builder") -> None: host.exec0("unset", "LD_LIBRARY_PATH") host.exec0("source", self.env_script) @@ -85,7 +82,7 @@ def __init__(self, arch: str, prefix: str) -> None: self.arch = arch self.prefix = prefix - def enable(self, host: H) -> None: + def enable(self, host: "Builder") -> None: host.env("ARCH", self.arch) host.env("CROSS_COMPILE", self.prefix)