Skip to content

Commit

Permalink
Add a few docstrings to hooks classes and implement Hook.__bool__
Browse files Browse the repository at this point in the history
  • Loading branch information
chadrik committed Jun 5, 2017
1 parent a9cc3ca commit 724c484
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mypy/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def locate(path: str) -> Optional[object]:


class Hook(Generic[T]):
"""
Holds a single hook function and its options dictionary
"""

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

def __bool__(self) -> bool:
return self.func is not None


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


class Hooks:
"""
Holds all known hooks
"""

def __init__(self) -> None:
self.docstring_parser = DocstringParserHook()

Expand Down

0 comments on commit 724c484

Please sign in to comment.