From 4e7a8a0d19df62855eaa42d23c24a12a6b27d0cb Mon Sep 17 00:00:00 2001 From: Tuomas Ahola Date: Fri, 9 Feb 2024 13:02:59 +0200 Subject: [PATCH] Fix some glitches in plugins/filetypes.py (#1440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Don’t upset dacite when the filetype is None. * Sync a new file’s type correctly to the menu. --- porcupine/plugins/filetypes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/porcupine/plugins/filetypes.py b/porcupine/plugins/filetypes.py index 55c5a6320..a10c65e18 100644 --- a/porcupine/plugins/filetypes.py +++ b/porcupine/plugins/filetypes.py @@ -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: @@ -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)