Skip to content

Commit

Permalink
amend! machine.linux: Fix a mypy error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Rahix committed Aug 1, 2024
1 parent 3cab905 commit d2a9e5a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tbot/machine/linux/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -52,15 +49,15 @@ def toolchains(self):
}
"""

def __init__(self, path: path.Path[H]) -> None:
def __init__(self, path: "path.Path[Builder]") -> None:
"""
Create a new EnvScriptToolchain.
:param linux.Path path: Path to the env script
"""
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)

Expand All @@ -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)

Expand Down

0 comments on commit d2a9e5a

Please sign in to comment.