Commit 5562ed7d authored by Bram Schoenmakers's avatar Bram Schoenmakers

Got rid of some invalid super() calls in EditCommand.

* Moved one super() call outside the EditCommand class into a lambda
  function.
* Made EditCommand.execute() call its correct parent execute() (was:
  ListCommand). However, this would go wrong:

  EditCommand.execute() calls MultiCommand.execute()
  MultiCommand.execute() calls ListCommand.execute()
      Because EditCommand has multiple inheritance
  ListCommand.execute() is successful, but returns None
  MultiCommand.execute() takes that as failure, returns False
  EditCommand.execute() returns False

  This is fixed by adding return True to the execute() method of the
  parent classes.

This fixes all pylint errors.
parent 72a2bed0
......@@ -26,6 +26,10 @@ from topydo.lib.TodoListBase import InvalidTodoException
from topydo.lib.TodoList import TodoList
from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
# Access the base class of the TodoList instance kept inside EditCommand. We
# cannot use super() inside the class itself
BASE_TODOLIST = lambda tl: super(TodoList, tl)
class EditCommand(MultiCommand, ListCommand):
def __init__(self, p_args, p_todolist, p_output, p_error, p_input):
super(EditCommand, self).__init__(p_args, p_todolist, p_output,
......@@ -87,7 +91,7 @@ class EditCommand(MultiCommand, ListCommand):
return None
def execute(self):
if not super(ListCommand, self).execute():
if not super(EditCommand, self).execute():
return False
self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
......@@ -123,7 +127,7 @@ class EditCommand(MultiCommand, ListCommand):
new_todos = self._todos_from_temp(temp_todos)
if len(new_todos) == len(self.todos):
for todo in self.todos:
super(TodoList, self.todolist).delete(todo)
BASE_TODOLIST(self.todolist).delete(todo)
for todo in new_todos:
self.todolist.add_todo(todo)
......
......@@ -102,6 +102,8 @@ class ListCommand(Command):
self._process_flags()
self._print()
return True
def usage(self):
return """Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
......
......@@ -81,3 +81,5 @@ class MultiCommand(Command):
else:
for error in todo_errors:
self.error(error)
return True
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment