Skip to content

Commit 724c484

Browse files
committed
Add a few docstrings to hooks classes and implement Hook.__bool__
1 parent a9cc3ca commit 724c484

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mypy/hooks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def locate(path: str) -> Optional[object]:
7373

7474

7575
class Hook(Generic[T]):
76+
"""
77+
Holds a single hook function and its options dictionary
78+
"""
7679

7780
def __init__(self) -> None:
7881
self.func = None # type: T
@@ -87,6 +90,9 @@ def __ne__(self, other: object) -> bool:
8790
def __repr__(self) -> str:
8891
return 'Hook({}, {})'.format(self.func, self.options)
8992

93+
def __bool__(self) -> bool:
94+
return self.func is not None
95+
9096

9197
# The docstring_parser hook is called for each unannotated function that has a
9298
# docstring. The callable should accept four arguments:
@@ -108,6 +114,10 @@ def __repr__(self) -> str:
108114

109115

110116
class Hooks:
117+
"""
118+
Holds all known hooks
119+
"""
120+
111121
def __init__(self) -> None:
112122
self.docstring_parser = DocstringParserHook()
113123

0 commit comments

Comments
 (0)