#366 Add type annotations in core components

This commit is contained in:
nvbn
2015-09-08 15:54:07 +03:00
parent eb17e696c3
commit dfa22bc92b
4 changed files with 107 additions and 7 deletions
+5
View File
@@ -54,6 +54,7 @@ class CommandSelector(object):
"""Helper for selecting rule from rules list."""
def __init__(self, commands):
""":type commands: Iterable[thefuck.types.CorrectedCommand]"""
self._commands_gen = commands
try:
self._commands = [next(self._commands_gen)]
@@ -77,6 +78,7 @@ class CommandSelector(object):
@property
def value(self):
""":rtype hefuck.types.CorrectedCommand"""
return self._commands[self._index]
@@ -87,6 +89,9 @@ def select_command(corrected_commands):
- None when ctrl+c pressed;
- selected command.
:type corrected_commands: Iterable[thefuck.types.CorrectedCommand]
:rtype: thefuck.types.CorrectedCommand | None
"""
try:
selector = CommandSelector(corrected_commands)