Skip to content

Commit

Permalink
refactor: remove redundant variable (didn't actually do what it was s…
Browse files Browse the repository at this point in the history
…upposed to do)
  • Loading branch information
mecaneer23 committed May 2, 2024
1 parent 687a4d0 commit 6659b7e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ def remove_file(filename: Path) -> int:
return 0


def quit_program(todos: Todos, created_new_file: bool, prev_time: float) -> int:
def quit_program(todos: Todos, prev_time: float) -> int:
"""Exit the program, writing to disk first"""
todos, _ = update_modified_time(prev_time, todos)
if created_new_file and len(todos) == 0:
if len(todos) == 0:
return remove_file(FILENAME)
return update_file(FILENAME, todos)

Expand Down Expand Up @@ -490,11 +490,6 @@ def main(stdscr: curses.window) -> int:
color and indentation level. Used for copy/paste
operations.
created_new_file:
bool, used to indicate whether the file was newly
created and modified or not, determines whether
to delete file in quit_program()
file_modified_time:
Last time of file modification. Used to determine
when to overwrite the save file.
Expand All @@ -506,7 +501,6 @@ def main(stdscr: curses.window) -> int:
history = UndoRedo()
single_line_state = SingleLineModeImpl(SingleLineMode.ON)
copied_todo = Todo()
created_new_file = len(todos) == 0
file_modified_time = get_file_modified_time(FILENAME)
# if adding a new feature that updates `todos`,
# make sure it also calls update_file()
Expand Down Expand Up @@ -617,7 +611,7 @@ def main(stdscr: curses.window) -> int:
},
)
if isinstance(next_step, Todos):
return quit_program(next_step, created_new_file, file_modified_time)
return quit_program(next_step, file_modified_time)
if next_step not in (
Key.ctrl_r,
Key.u,
Expand Down

0 comments on commit 6659b7e

Please sign in to comment.