Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Aug 9, 2024
1 parent 2a771eb commit 7494bd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
11 changes: 4 additions & 7 deletions plugin/ui/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,8 @@ def conversation(self, value: list[CopilotPayloadConversationEntry]) -> None:
# normal methods #
# -------------- #

def __init__(self, window: sublime.Window | None) -> None:
if not window:
raise ValueError("window is required")

self.window: sublime.Window = window
def __init__(self, window: sublime.Window) -> None:
self.window = window

def reset(self) -> None:
self.is_waiting = False
Expand Down Expand Up @@ -181,8 +178,8 @@ def close(self) -> None:

class _ConversationEntry:
def __init__(self, window: sublime.Window) -> None:
self.window: sublime.Window = window
self.wcm: WindowConversationManager = WindowConversationManager(window)
self.window = window
self.wcm = WindowConversationManager(window)

@property
def completion_content(self) -> str:
Expand Down
16 changes: 3 additions & 13 deletions plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,15 @@ def fix_completion_syntax_highlight(view: sublime.View, point: int, code: str) -
return code


def get_copilot_setting(
instance: sublime.Window | sublime.View | None, prefix: str, key: str, default: Any = None
) -> Any:
if not instance:
return
def get_copilot_setting(instance: sublime.Window | sublime.View, prefix: str, key: str, default: Any = None) -> Any:
return instance.settings().get(f"{prefix}.{key}", default)


def set_copilot_setting(
instance: sublime.Window | sublime.View | None, prefix: str, key: str, default: Any = None
) -> Any:
if not instance:
return
def set_copilot_setting(instance: sublime.Window | sublime.View, prefix: str, key: str, default: Any = None) -> Any:
instance.settings().set(f"{prefix}.{key}", default)


def erase_copilot_setting(instance: sublime.Window | sublime.View | None, prefix: str, key: str) -> Any:
if not instance:
return
def erase_copilot_setting(instance: sublime.Window | sublime.View, prefix: str, key: str) -> Any:
instance.settings().erase(f"{prefix}.{key}")


Expand Down

0 comments on commit 7494bd8

Please sign in to comment.