Skip to content

Commit 9891bbe

Browse files
tool protocol
1 parent 8a1d031 commit 9891bbe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/dl_formula_testing/dl_formula_testing/tool_runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import argparse
34
from contextlib import (
45
contextmanager,
56
redirect_stderr,
@@ -11,6 +12,7 @@
1112
TYPE_CHECKING,
1213
Generator,
1314
Optional,
15+
Protocol,
1416
TextIO,
1517
)
1618

@@ -19,6 +21,12 @@
1921
from argparse import ArgumentParser
2022

2123

24+
class Tool(Protocol):
25+
@classmethod
26+
def run(cls, args: argparse.Namespace) -> None:
27+
raise NotImplementedError()
28+
29+
2230
@contextmanager
2331
def redirect_stdin(stream: Optional[TextIO] = None) -> Generator[None, None, None]:
2432
if stream is None:
@@ -34,7 +42,7 @@ def redirect_stdin(stream: Optional[TextIO] = None) -> Generator[None, None, Non
3442

3543

3644
class ToolRunner:
37-
def __init__(self, parser: ArgumentParser, tool_cls: type):
45+
def __init__(self, parser: ArgumentParser, tool_cls: type[Tool]):
3846
self.parser = parser
3947
self.tool_cls = tool_cls
4048

0 commit comments

Comments
 (0)