Skip to content

Commit

Permalink
Merge pull request #1946 from timbrel/mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Sep 1, 2024
2 parents 20b7257 + 45e5bec commit 8748223
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 30 deletions.
6 changes: 3 additions & 3 deletions core/commands/blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class gs_blame_current_file(LogMixin, GsTextCommand):
_commit_hash = None
_file_path = None

def run(self, edit, **kwargs):
def run(self, edit, **kwargs): # type: ignore[override]
# reset memorized commit hash when blaming a different file
if self._file_path != self.file_path:
self._commit_hash = None
Expand All @@ -145,10 +145,10 @@ def do_action(self, commit_hash, **kwargs):
"commit_hash": commit_hash, "file_path": self._file_path
})

def selected_index(self, commit_hash):
def selected_index(self, commit_hash): # type: ignore[override]
return self._commit_hash == commit_hash

def log(self, **kwargs):
def log(self, **kwargs): # type: ignore[override]
follow = self.savvy_settings.get("blame_follow_rename")
kwargs["follow"] = follow
return super().log(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class gs_checkout_current_file_at_commit(LogMixin, WindowCommand, GitCommand):
Reset the current active file to a given commit.
"""

def run(self):
def run(self): # type: ignore[override]
if self.file_path:
super().run(file_path=self.file_path)

Expand Down
2 changes: 1 addition & 1 deletion core/commands/cherry_pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class gs_cherry_pick(gs_log_by_branch):

def log(self, **kwargs):
def log(self, **kwargs): # type: ignore[override]
kwargs["cherry"] = True
kwargs["start_end"] = ("", kwargs["branch"])
return super().log(**kwargs)
Expand Down
8 changes: 4 additions & 4 deletions core/commands/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class GsFixupFromStageCommand(gs_log_current_branch):
def run(self):
def run(self): # type: ignore[override]
status = self.get_working_dir_status()
if status.unstaged_files or status.merge_conflicts:
sublime.message_dialog(
Expand Down Expand Up @@ -43,8 +43,8 @@ def auto_squash(self, commit_chain):

return commit_chain

def do_action(self, commit, **kwargs):
commit = self.git("rev-parse", commit).strip()
def do_action(self, commit_hash, **kwargs):
commit = self.git("rev-parse", commit_hash).strip()
self.git("commit", "--fixup", commit)
try:
base_commit = self.git("rev-parse", "{}~1".format(commit)).strip()
Expand All @@ -61,6 +61,6 @@ def do_action(self, commit, **kwargs):


class GsQuickStageCurrentFileAndFixupCommand(GsFixupFromStageCommand):
def run(self):
def run(self): # type: ignore[override]
self.git("add", "--", self.file_path)
super().run()
8 changes: 4 additions & 4 deletions core/commands/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class LogMixin(GitCommand):

selected_index: Union[int, Callable[[str], bool]] = 0

def run(self, *args, commit_hash=None, file_path=None, **kwargs):
def run(self, *, commit_hash=None, file_path=None, **kwargs):
if commit_hash:
self.do_action(commit_hash, file_path=file_path, **kwargs)
else:
sublime.set_timeout_async(lambda: self.run_async(file_path=file_path, **kwargs))

def run_async(self, file_path=None, **kwargs):
def run_async(self, *, file_path=None, **kwargs):
follow = self.savvy_settings.get("log_follow_rename") if file_path else False
entries = self.log_generator(file_path=file_path, follow=follow, **kwargs)
# `on_highlight` gets called on `on_done` as well with the same
Expand Down Expand Up @@ -119,7 +119,7 @@ class gs_log_current_branch(LogMixin, WindowCommand, GitCommand):

class gs_log_all_branches(LogMixin, WindowCommand, GitCommand):

def log(self, **kwargs):
def log(self, **kwargs): # type: ignore[override]
return super().log(all_branches=True, **kwargs)


Expand Down Expand Up @@ -163,7 +163,7 @@ def on_author_selection(self, index, **kwargs):
self._selected_author = self._entries[index][3]
super().run_async(**kwargs)

def log(self, **kwargs):
def log(self, **kwargs): # type: ignore[override]
return super().log(author=self._selected_author, **kwargs)


Expand Down
28 changes: 17 additions & 11 deletions core/commands/log_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,13 +1176,19 @@ def drain_and_draw_queue(view, painter_state, follow, col_range, visible_selecti
col_range,
visible_selection,
)
try_navigate_to_symbol = partial(
navigate_to_symbol,
view,
follow,
col_range=col_range,
method=set_and_show_cursor if visible_selection else just_set_cursor
)

if not follow:
def try_navigate_to_symbol(*, if_before=None) -> bool:
return False
else:
try_navigate_to_symbol = partial(
navigate_to_symbol,
view,
follow,
col_range=col_range,
method=set_and_show_cursor if visible_selection else just_set_cursor
)

block_time = utils.timer()
while True:
# If only the head commits changed, and the cursor (and with it `follow`)
Expand Down Expand Up @@ -1224,7 +1230,7 @@ def drain_and_draw_queue(view, painter_state, follow, col_range, visible_selecti
# If we still did not navigate the symbol is either
# gone, or happens to be after the fold of fresh
# content.
if not follow or not try_navigate_to_symbol():
if not try_navigate_to_symbol():
if initial_draw:
view.run_command("gs_log_graph_navigate")
elif visible_selection:
Expand Down Expand Up @@ -3114,13 +3120,13 @@ def get_list(info, key):
]
return actions

def pull(self):
def pull(self): # type: ignore[override]
self.window.run_command("gs_pull")

def push(self, current_branch):
def push(self, current_branch): # type: ignore[override]
self.window.run_command("gs_push", {"local_branch_name": current_branch})

def fetch(self, current_branch):
def fetch(self, current_branch): # type: ignore[override]
remote = self.get_remote_for_branch(current_branch)
self.window.run_command("gs_fetch", {"remote": remote} if remote else None)

Expand Down
4 changes: 2 additions & 2 deletions core/commands/log_graph_rebase_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,13 @@ class gs_rebase_reword_commit(gs_rebase_quick_action):


class gs_rebase_apply_fixup(gs_rebase_quick_action):
def run(self, edit, base_commit, fixes):
def run(self, edit, base_commit, fixes): # type: ignore[override]
self.action = partial(fixup_commits, [Commit(*fix) for fix in fixes])
super().run(edit, base_commit)


class gs_rebase_squash_commits(gs_rebase_quick_action):
def run(self, edit, base_commit, commits):
def run(self, edit, base_commit, commits): # type: ignore[override]
self.action = partial(squash_commits, commits)
super().run(edit, base_commit)

Expand Down
2 changes: 1 addition & 1 deletion core/commands/show_file_at_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def do_action(self, commit_hash, **kwargs):
"lang": view.settings().get('syntax')
})

def selected_index(self, commit_hash):
def selected_index(self, commit_hash): # type: ignore[override]
if not self.overlay_for_show_file_at_commit:
return True

Expand Down
6 changes: 3 additions & 3 deletions core/interfaces/rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def run_async(self):
self.do_action(self.interface.entries[squash_idx - 1].long_hash)
else:
reversed_logs = list(reversed(self.interface.entries[0:squash_idx]))
show_log_panel(reversed_logs, partial(enqueue_on_worker, self.do_action))
show_log_panel(reversed_logs, partial(enqueue_on_worker, self.do_action)) # type: ignore[call-arg]

def do_action(self, target_commit):
if not target_commit:
Expand Down Expand Up @@ -733,7 +733,7 @@ def run_async(self):
self.do_action(self.interface.entries[move_idx - 1].long_hash)
else:
logs = list(reversed(self.interface.entries[:move_idx]))
show_log_panel(logs, partial(enqueue_on_worker, self.do_action))
show_log_panel(logs, partial(enqueue_on_worker, self.do_action)) # type: ignore[call-arg]

def do_action(self, target_commit):
if not target_commit:
Expand Down Expand Up @@ -785,7 +785,7 @@ def run_async(self):
self.do_action(self.interface.entries[move_idx + 1].long_hash)
else:
logs = self.interface.entries[move_idx + 1:]
show_log_panel(logs, partial(enqueue_on_worker, self.do_action))
show_log_panel(logs, partial(enqueue_on_worker, self.do_action)) # type: ignore[call-arg]

def do_action(self, target_commit):
if not target_commit:
Expand Down

0 comments on commit 8748223

Please sign in to comment.