Skip to content

Commit

Permalink
Fix some glitches in plugins/filetypes.py (Akuli#1440)
Browse files Browse the repository at this point in the history
* Don’t upset dacite when the filetype is None.
* Sync a new file’s type correctly to the menu.
  • Loading branch information
taahol authored Feb 9, 2024
1 parent d35e12e commit 4e7a8a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions porcupine/plugins/filetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ def parse_filetype_name(name: str) -> FileType:

def _sync_filetypes_menu(event: object = None) -> None:
tab = get_tab_manager().select()
filetype_name: str = ""
filetype_name: str | None = ""
if isinstance(tab, tabs.FileTab):
try:
filetype_name = tab.settings.get("filetype_name", str)
filetype_name = tab.settings.get("filetype_name", Optional[str])
except KeyError:
pass

filetypes_var.set(filetype_name)
filetypes_var.set(filetype_name or "")


def _add_filetype_menuitem(name: str, tk_var: tkinter.StringVar) -> None:
Expand Down Expand Up @@ -278,5 +278,5 @@ def setup() -> None:
new_file_filetypes = get_parsed_args().new_file or [] # argparse can give None
for filetype in new_file_filetypes:
tab = tabs.FileTab(get_tab_manager())
get_tab_manager().add_tab(tab) # sets default filetype
apply_filetype_to_tab(filetype, tab) # sets correct filetype
get_tab_manager().add_tab(tab)

0 comments on commit 4e7a8a0

Please sign in to comment.