From 92da1244fbc014ffec3601992e21f74179b4b173 Mon Sep 17 00:00:00 2001 From: Romain Failliot Date: Sun, 9 Jan 2022 15:19:12 -0500 Subject: [PATCH] Add static typing for utils.EncodingMenu --- src/diffuse/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffuse/utils.py b/src/diffuse/utils.py index 92a69ea..5e129cc 100644 --- a/src/diffuse/utils.py +++ b/src/diffuse/utils.py @@ -55,7 +55,7 @@ class MessageDialog(Gtk.MessageDialog): # widget to help pick an encoding class EncodingMenu(Gtk.Box): - def __init__(self, prefs, autodetect=False): + def __init__(self, prefs: Preferences, autodetect: bool = False) -> None: Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) self.combobox = combobox = Gtk.ComboBoxText.new() self.encodings = prefs.getEncodings()[:] @@ -67,12 +67,12 @@ class EncodingMenu(Gtk.Box): self.pack_start(combobox, False, False, 0) combobox.show() - def set_text(self, encoding): + def set_text(self, encoding: Optional[str]) -> None: encoding = norm_encoding(encoding) if encoding in self.encodings: self.combobox.set_active(self.encodings.index(encoding)) - def get_text(self): + def get_text(self) -> Optional[str]: i = self.combobox.get_active() return self.encodings[i] if i >= 0 else None