Skip to content

Commit

Permalink
topotato: new mypy, new warnings
Browse files Browse the repository at this point in the history
Updating mypy and/or pytest brought in a few more complaints.

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Sep 23, 2024
1 parent e89e1da commit a60c01d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions topotato/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ def __init__(self, daemon: str, router: str, cmdline: Optional[str] = None):
self.cmdline = cmdline
super().__init__()

def __str__(self):
def __repr__(self) -> str:
if self.cmdline:
return f"{self.router}/{self.daemon}: {self.cmdline}"
return f"{self.router}/{self.daemon}"

__str__ = __repr__

@attr.s(eq=False, auto_attribs=True)
class TopotatoRepr(TerminalRepr):
excinfo: ExceptionInfo
Expand Down Expand Up @@ -169,7 +171,7 @@ def __init__(self, failed_node, *args, **kwargs):
super().__init__(*args, **kwargs)
self.failed_node = failed_node

def __str__(self):
def __repr__(self) -> str:
fno = self.failed_node
parentnodeid = fno.parent.nodeid if fno.parent else ""
sub_id = fno.nodeid.removeprefix(parentnodeid)
Expand All @@ -179,6 +181,8 @@ def __str__(self):
cause = "???"
return f"{cause} in {sub_id}"

__str__ = __repr__


# test coding errors

Expand Down
8 changes: 5 additions & 3 deletions topotato/frr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ def pytest_addoption(parser):
def pytest_topotato_envcheck(cls, session: "ISession", result: EnvcheckResult):
frrpath = get_dir(session, "--frr-builddir", "frr_builddir")

session.frr = cls(frrpath, result)
session.frr = cast(Self, cls(frrpath, result))
cls.setups[None] = session.frr

for section in session.control.typed_sections.get(TargetFRRSection, []):
_logger.debug("additional loading %r", section)
setup = cls(os.path.expanduser(section.builddir), result)
setup = cast(Self, cls(os.path.expanduser(section.builddir), result))
cls.setups[section.name] = setup

def __init__(self, frrpath: str, result: EnvcheckResult):
Expand Down Expand Up @@ -468,9 +468,11 @@ def __init__(self, router: str, daemon: str, errmsg: str):
self.errmsg = errmsg
super().__init__()

def __str__(self):
def __repr__(self) -> str:
return f"{self.router}/{self.daemon}: {self.errmsg}"

__str__ = __repr__


# pylint: disable=too-many-ancestors,too-many-instance-attributes
class FRRRouterNS(TopotatoNetwork.RouterNS):
Expand Down
4 changes: 3 additions & 1 deletion topotato/frr/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def __init__(
self.config = config
super().__init__()

def __str__(self):
def __repr__(self) -> str:
return f"{self.router}/startup-config-load"

__str__ = __repr__

@attr.s(eq=False, auto_attribs=True)
class TopotatoRepr(TerminalRepr):
excinfo: ExceptionInfo
Expand Down

0 comments on commit a60c01d

Please sign in to comment.