Daniel Brötzmann pushed to branch mainwindow at gajim / gajim

Commits:

5 changed files:

Changes:

  • gajim/gtk/account_wizard.py
    ... ... @@ -12,6 +12,11 @@
    12 12
     # You should have received a copy of the GNU General Public License
    
    13 13
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    14 14
     
    
    15
    +from typing import Optional
    
    16
    +from typing import List
    
    17
    +from typing import Tuple
    
    18
    +from typing import Union
    
    19
    +
    
    15 20
     import logging
    
    16 21
     
    
    17 22
     from gi.repository import Gdk
    
    ... ... @@ -54,10 +59,10 @@
    54 59
     
    
    55 60
     
    
    56 61
     class AccountWizard(Assistant):
    
    57
    -    def __init__(self):
    
    62
    +    def __init__(self) -> None:
    
    58 63
             Assistant.__init__(self, height=500)
    
    59 64
     
    
    60
    -        self._destroyed = False
    
    65
    +        self._destroyed: bool = False
    
    61 66
     
    
    62 67
             self.add_button('signup', _('Sign Up'), complete=True,
    
    63 68
                             css_class='suggested-action')
    
    ... ... @@ -88,10 +93,10 @@ def __init__(self):
    88 93
     
    
    89 94
             self.update_proxy_list()
    
    90 95
     
    
    91
    -        self._client = None
    
    92
    -        self._method = 'login'
    
    96
    +        self._client: Optional[Client] = None
    
    97
    +        self._method: str = 'login'
    
    93 98
     
    
    94
    -    def get_currenct_method(self):
    
    99
    +    def get_currenct_method(self) -> str:
    
    95 100
             return self._method
    
    96 101
     
    
    97 102
         def _on_button_clicked(self, _page, button_name):
    
    ... ... @@ -190,15 +195,16 @@ def _on_page_changed(self, _assistant, page_name):
    190 195
             elif page_name == 'form':
    
    191 196
                 self.get_page('form').focus()
    
    192 197
     
    
    193
    -    def update_proxy_list(self):
    
    198
    +    def update_proxy_list(self) -> None:
    
    194 199
             self.get_page('advanced').update_proxy_list()
    
    195 200
     
    
    196 201
         def _get_base_client(self,
    
    197
    -                         domain,
    
    198
    -                         username,
    
    199
    -                         mode,
    
    200
    -                         advanced,
    
    201
    -                         ignore_all_errors):
    
    202
    +                         domain: str,
    
    203
    +                         username: str,
    
    204
    +                         mode: Mode,
    
    205
    +                         advanced: bool,
    
    206
    +                         ignore_all_errors: bool
    
    207
    +                         ) -> Client:
    
    202 208
     
    
    203 209
             client = Client(log_context='Account Wizard')
    
    204 210
             client.set_domain(domain)
    
    ... ... @@ -224,7 +230,7 @@ def _get_base_client(self,
    224 230
             client.subscribe('stanza-received', self._on_stanza_received)
    
    225 231
             return client
    
    226 232
     
    
    227
    -    def _disconnect(self):
    
    233
    +    def _disconnect(self) -> None:
    
    228 234
             if self._client is None:
    
    229 235
                 return
    
    230 236
             self._client.remove_subscriptions()
    
    ... ... @@ -243,7 +249,7 @@ def _on_stanza_received(_client, _signal_name, stanza):
    243 249
                                                      account='AccountWizard',
    
    244 250
                                                      stanza=stanza))
    
    245 251
     
    
    246
    -    def _test_credentials(self, ignore_all_errors=False):
    
    252
    +    def _test_credentials(self, ignore_all_errors: bool = False) -> None:
    
    247 253
             self._show_progress_page(_('Connecting...'),
    
    248 254
                                      _('Connecting to server...'))
    
    249 255
             address, password = self.get_page('login').get_credentials()
    
    ... ... @@ -262,7 +268,7 @@ def _test_credentials(self, ignore_all_errors=False):
    262 268
     
    
    263 269
             self._client.connect()
    
    264 270
     
    
    265
    -    def _test_anonymous_server(self, ignore_all_errors=False):
    
    271
    +    def _test_anonymous_server(self, ignore_all_errors: bool = False) -> None:
    
    266 272
             self._show_progress_page(_('Connecting...'),
    
    267 273
                                      _('Connecting to server...'))
    
    268 274
             domain = self.get_page('signup').get_server()
    
    ... ... @@ -279,7 +285,7 @@ def _test_anonymous_server(self, ignore_all_errors=False):
    279 285
                                    self._on_anonymous_supported)
    
    280 286
             self._client.connect()
    
    281 287
     
    
    282
    -    def _register_with_server(self, ignore_all_errors=False):
    
    288
    +    def _register_with_server(self, ignore_all_errors: bool = False) -> None:
    
    283 289
             self._show_progress_page(_('Connecting...'),
    
    284 290
                                      _('Connecting to server...'))
    
    285 291
             domain = self.get_page('signup').get_server()
    
    ... ... @@ -380,19 +386,19 @@ def _on_connection_failed(self, _client, _signal_name):
    380 386
             self._client.destroy()
    
    381 387
             self._client = None
    
    382 388
     
    
    383
    -    def _show_error_page(self, title, heading, text):
    
    389
    +    def _show_error_page(self, title: str, heading: str, text: str) -> None:
    
    384 390
             self.get_page('error').set_title(title)
    
    385 391
             self.get_page('error').set_heading(heading)
    
    386 392
             self.get_page('error').set_text(text or '')
    
    387 393
             self.show_page('error', Gtk.StackTransitionType.SLIDE_LEFT)
    
    388 394
     
    
    389
    -    def _show_progress_page(self, title, text):
    
    395
    +    def _show_progress_page(self, title: str, text: str) -> None:
    
    390 396
             self._progress.set_title(title)
    
    391 397
             self._progress.set_text(text)
    
    392 398
             self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT)
    
    393 399
     
    
    394 400
         @staticmethod
    
    395
    -    def _generate_account_name(domain):
    
    401
    +    def _generate_account_name(domain: str) -> str:
    
    396 402
             i = 1
    
    397 403
             while domain in app.settings.get_accounts():
    
    398 404
                 domain = domain + str(i)
    
    ... ... @@ -429,7 +435,7 @@ def _on_register_form(self, task):
    429 435
     
    
    430 436
             self.show_page('form', Gtk.StackTransitionType.SLIDE_LEFT)
    
    431 437
     
    
    432
    -    def _submit_form(self):
    
    438
    +    def _submit_form(self) -> None:
    
    433 439
             self.get_page('progress').set_text(_('Account is being created'))
    
    434 440
             self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT)
    
    435 441
     
    
    ... ... @@ -486,7 +492,11 @@ def _on_register_result(self, task):
    486 492
             self.get_page('form').remove_form()
    
    487 493
             self._disconnect()
    
    488 494
     
    
    489
    -    def _set_error_text(self, error):
    
    495
    +    def _set_error_text(self,
    
    496
    +                        error: Union[StanzaError,
    
    497
    +                                     RegisterStanzaError,
    
    498
    +                                     MalformedStanzaError]
    
    499
    +                        ) -> None:
    
    490 500
             error_text = error.get_text()
    
    491 501
             if not error_text:
    
    492 502
                 error_text = _('The server rejected the registration '
    
    ... ... @@ -504,7 +514,7 @@ class Login(Page):
    504 514
             'clicked': (GObject.SignalFlags.RUN_LAST, None, (str,)),
    
    505 515
         }
    
    506 516
     
    
    507
    -    def __init__(self):
    
    517
    +    def __init__(self) -> None:
    
    508 518
             Page.__init__(self)
    
    509 519
             self.title = _('Add Account')
    
    510 520
     
    
    ... ... @@ -525,7 +535,7 @@ def __init__(self):
    525 535
             self.pack_start(self._ui.login_box, True, True, 0)
    
    526 536
             self.show_all()
    
    527 537
     
    
    528
    -    def focus(self):
    
    538
    +    def focus(self) -> None:
    
    529 539
             self._ui.log_in_address_entry.grab_focus()
    
    530 540
     
    
    531 541
         def _on_login(self, *args):
    
    ... ... @@ -534,7 +544,7 @@ def _on_login(self, *args):
    534 544
         def _on_signup(self, *args):
    
    535 545
             self.emit('clicked', 'signup')
    
    536 546
     
    
    537
    -    def _create_server_completion(self):
    
    547
    +    def _create_server_completion(self) -> None:
    
    538 548
             # Parse servers.json
    
    539 549
             file_path = configpaths.get('DATA') / 'other' / 'servers.json'
    
    540 550
             self._servers = helpers.load_json(file_path, default=[])
    
    ... ... @@ -561,9 +571,9 @@ def _update_completion(self, entry):
    561 571
             model.clear()
    
    562 572
     
    
    563 573
             for server in self._servers:
    
    564
    -            model.append(['%s@%s' % (text, server)])
    
    574
    +            model.append([f'{text}@{server}'])
    
    565 575
     
    
    566
    -    def _show_icon(self, show):
    
    576
    +    def _show_icon(self, show: bool) -> None:
    
    567 577
             icon = 'dialog-warning-symbolic' if show else None
    
    568 578
             self._ui.log_in_address_entry.set_icon_from_icon_name(
    
    569 579
                 Gtk.EntryIconPosition.SECONDARY, icon)
    
    ... ... @@ -575,7 +585,7 @@ def _on_password_entry_activate(self, _widget):
    575 585
             if self._ui.log_in_button.get_sensitive():
    
    576 586
                 self._ui.log_in_button.activate()
    
    577 587
     
    
    578
    -    def _validate_jid(self, address):
    
    588
    +    def _validate_jid(self, address: str) -> bool:
    
    579 589
             if not address:
    
    580 590
                 self._show_icon(False)
    
    581 591
                 return False
    
    ... ... @@ -598,10 +608,10 @@ def _set_complete(self, *args):
    598 608
             password = self._ui.log_in_password_entry.get_text()
    
    599 609
             self._ui.log_in_button.set_sensitive(address and password)
    
    600 610
     
    
    601
    -    def is_advanced(self):
    
    611
    +    def is_advanced(self) -> bool:
    
    602 612
             return self._ui.login_advanced_checkbutton.get_active()
    
    603 613
     
    
    604
    -    def get_credentials(self):
    
    614
    +    def get_credentials(self) -> Tuple[str, str]:
    
    605 615
             data = (self._ui.log_in_address_entry.get_text(),
    
    606 616
                     self._ui.log_in_password_entry.get_text())
    
    607 617
             return data
    
    ... ... @@ -610,8 +620,8 @@ def get_credentials(self):
    610 620
     class Signup(Page):
    
    611 621
         def __init__(self):
    
    612 622
             Page.__init__(self)
    
    613
    -        self.complete = False
    
    614
    -        self.title = _('Create New Account')
    
    623
    +        self.complete: bool = False
    
    624
    +        self.title: str = _('Create New Account')
    
    615 625
     
    
    616 626
             self._ui = get_builder('account_wizard.ui')
    
    617 627
             self._ui.server_comboboxtext_sign_up_entry.set_activates_default(True)
    
    ... ... @@ -630,10 +640,10 @@ def __init__(self):
    630 640
     
    
    631 641
             self.show_all()
    
    632 642
     
    
    633
    -    def focus(self):
    
    643
    +    def focus(self) -> None:
    
    634 644
             self._ui.server_comboboxtext_sign_up_entry.grab_focus()
    
    635 645
     
    
    636
    -    def _create_server_completion(self):
    
    646
    +    def _create_server_completion(self) -> None:
    
    637 647
             # Parse servers.json
    
    638 648
             file_path = configpaths.get('DATA') / 'other' / 'servers.json'
    
    639 649
             servers = helpers.load_json(file_path, default=[])
    
    ... ... @@ -650,7 +660,7 @@ def _create_server_completion(self):
    650 660
     
    
    651 661
         def _on_visit_server(self, _widget):
    
    652 662
             server = self._ui.server_comboboxtext_sign_up_entry.get_text().strip()
    
    653
    -        server = 'https://' + server
    
    663
    +        server = f'https://{server}'
    
    654 664
             open_uri(server)
    
    655 665
             return Gdk.EVENT_STOP
    
    656 666
     
    
    ... ... @@ -666,13 +676,13 @@ def _set_complete(self, *args):
    666 676
     
    
    667 677
             self.update_page_complete()
    
    668 678
     
    
    669
    -    def is_anonymous(self):
    
    679
    +    def is_anonymous(self) -> bool:
    
    670 680
             return self._ui.sign_up_anonymously.get_active()
    
    671 681
     
    
    672
    -    def is_advanced(self):
    
    682
    +    def is_advanced(self) -> bool:
    
    673 683
             return self._ui.sign_up_advanced_checkbutton.get_active()
    
    674 684
     
    
    675
    -    def get_server(self):
    
    685
    +    def get_server(self) -> str:
    
    676 686
             return validate_domainpart(
    
    677 687
                 self._ui.server_comboboxtext_sign_up_entry.get_text())
    
    678 688
     
    
    ... ... @@ -683,18 +693,18 @@ def _on_activate_link(_label, uri):
    683 693
             open_uri(uri)
    
    684 694
             return Gdk.EVENT_STOP
    
    685 695
     
    
    686
    -    def get_visible_buttons(self):
    
    696
    +    def get_visible_buttons(self) -> List[str]:
    
    687 697
             return ['back', 'signup']
    
    688 698
     
    
    689
    -    def get_default_button(self):
    
    699
    +    def get_default_button(self) -> str:
    
    690 700
             return 'signup'
    
    691 701
     
    
    692 702
     
    
    693 703
     class AdvancedSettings(Page):
    
    694 704
         def __init__(self):
    
    695 705
             Page.__init__(self)
    
    696
    -        self.title = _('Advanced settings')
    
    697
    -        self.complete = False
    
    706
    +        self.title: str = _('Advanced settings')
    
    707
    +        self.complete: bool = False
    
    698 708
     
    
    699 709
             self._ui = get_builder('account_wizard.ui')
    
    700 710
             self._ui.manage_proxies_button.connect('clicked',
    
    ... ... @@ -710,7 +720,7 @@ def __init__(self):
    710 720
         def _on_proxy_manager(_widget):
    
    711 721
             app.app.activate_action('manage-proxies')
    
    712 722
     
    
    713
    -    def update_proxy_list(self):
    
    723
    +    def update_proxy_list(self) -> None:
    
    714 724
             model = Gtk.ListStore(str)
    
    715 725
             self._ui.proxies_combobox.set_model(model)
    
    716 726
             proxies = app.settings.get_proxies()
    
    ... ... @@ -719,11 +729,13 @@ def update_proxy_list(self):
    719 729
                 model.append([proxy])
    
    720 730
             self._ui.proxies_combobox.set_active(0)
    
    721 731
     
    
    722
    -    def get_proxy(self):
    
    732
    +    def get_proxy(self) -> str:
    
    723 733
             active = self._ui.proxies_combobox.get_active()
    
    724 734
             return self._ui.proxies_combobox.get_model()[active][0]
    
    725 735
     
    
    726
    -    def get_custom_host(self):
    
    736
    +    def get_custom_host(self) -> Optional[Tuple[str,
    
    737
    +                                                ConnectionProtocol,
    
    738
    +                                                ConnectionType]]:
    
    727 739
             host = self._ui.custom_host_entry.get_text()
    
    728 740
             port = self._ui.custom_port_entry.get_text()
    
    729 741
             if not host or not port:
    
    ... ... @@ -735,21 +747,19 @@ def get_custom_host(self):
    735 747
             if host.startswith('ws://') or host.startswith('wss://'):
    
    736 748
                 protocol = ConnectionProtocol.WEBSOCKET
    
    737 749
     
    
    738
    -        return ('%s:%s' % (host, port),
    
    739
    -                protocol,
    
    740
    -                ConnectionType(con_type))
    
    750
    +        return (f'{host}:{port}', protocol, ConnectionType(con_type))
    
    741 751
     
    
    742
    -    def _show_host_icon(self, show):
    
    752
    +    def _show_host_icon(self, show: bool) -> None:
    
    743 753
             icon = 'dialog-warning-symbolic' if show else None
    
    744 754
             self._ui.custom_host_entry.set_icon_from_icon_name(
    
    745 755
                 Gtk.EntryIconPosition.SECONDARY, icon)
    
    746 756
     
    
    747
    -    def _show_port_icon(self, show):
    
    757
    +    def _show_port_icon(self, show: bool) -> None:
    
    748 758
             icon = 'dialog-warning-symbolic' if show else None
    
    749 759
             self._ui.custom_port_entry.set_icon_from_icon_name(
    
    750 760
                 Gtk.EntryIconPosition.SECONDARY, icon)
    
    751 761
     
    
    752
    -    def _validate_host(self):
    
    762
    +    def _validate_host(self) -> bool:
    
    753 763
             host = self._ui.custom_host_entry.get_text()
    
    754 764
             if host.startswith('ws://') or host.startswith('wss://'):
    
    755 765
                 # We have no method for validating websocket URIs
    
    ... ... @@ -767,7 +777,7 @@ def _validate_host(self):
    767 777
             self._show_host_icon(False)
    
    768 778
             return True
    
    769 779
     
    
    770
    -    def _validate_port(self):
    
    780
    +    def _validate_port(self) -> bool:
    
    771 781
             port = self._ui.custom_port_entry.get_text()
    
    772 782
             if not port:
    
    773 783
                 self._show_port_icon(False)
    
    ... ... @@ -791,12 +801,12 @@ def _validate_port(self):
    791 801
             self._show_port_icon(False)
    
    792 802
             return True
    
    793 803
     
    
    794
    -    def _is_custom_host_set(self):
    
    804
    +    def _is_custom_host_set(self) -> bool:
    
    795 805
             host = bool(self._ui.custom_host_entry.get_text())
    
    796 806
             port = bool(self._ui.custom_port_entry.get_text())
    
    797 807
             return host or port
    
    798 808
     
    
    799
    -    def _is_proxy_set(self):
    
    809
    +    def _is_proxy_set(self) -> bool:
    
    800 810
             return self._ui.proxies_combobox.get_active() != 0
    
    801 811
     
    
    802 812
         def _set_complete(self, *args):
    
    ... ... @@ -811,19 +821,19 @@ def _set_complete(self, *args):
    811 821
     
    
    812 822
             self.update_page_complete()
    
    813 823
     
    
    814
    -    def get_visible_buttons(self):
    
    824
    +    def get_visible_buttons(self) -> List[str]:
    
    815 825
             return ['back', self.get_toplevel().get_currenct_method()]
    
    816 826
     
    
    817
    -    def get_default_button(self):
    
    827
    +    def get_default_button(self) -> str:
    
    818 828
             return self.get_toplevel().get_currenct_method()
    
    819 829
     
    
    820 830
     
    
    821 831
     class SecurityWarning(Page):
    
    822
    -    def __init__(self):
    
    832
    +    def __init__(self) -> None:
    
    823 833
             Page.__init__(self)
    
    824
    -        self.title = _('Security Warning')
    
    825
    -        self._cert = None
    
    826
    -        self._domain = None
    
    834
    +        self.title: str = _('Security Warning')
    
    835
    +        self._cert: Optional[Gio.TlsCertificate] = None
    
    836
    +        self._domain: Optional[str] = None
    
    827 837
     
    
    828 838
             self._ui = get_builder('account_wizard.ui')
    
    829 839
             self.pack_start(self._ui.security_warning_box, True, True, 0)
    
    ... ... @@ -831,10 +841,14 @@ def __init__(self):
    831 841
             self.show_all()
    
    832 842
     
    
    833 843
         @property
    
    834
    -    def cert(self):
    
    844
    +    def cert(self) -> Optional[Gio.TlsCertificate]:
    
    835 845
             return self._cert
    
    836 846
     
    
    837
    -    def set_warning(self, domain, cert, errors):
    
    847
    +    def set_warning(self,
    
    848
    +                    domain: str,
    
    849
    +                    cert: Gio.TlsCertificate,
    
    850
    +                    errors: List[Gio.TlsCertificateFlags]
    
    851
    +                    ) -> None:
    
    838 852
             # Clear list
    
    839 853
             self._cert = cert
    
    840 854
             self._domain = domain
    
    ... ... @@ -866,22 +880,22 @@ def _on_view_cert(self, _button):
    866 880
                         cert=self._cert)
    
    867 881
     
    
    868 882
         @property
    
    869
    -    def trust_certificate(self):
    
    883
    +    def trust_certificate(self) -> bool:
    
    870 884
             return self._ui.trust_cert_checkbutton.get_active()
    
    871 885
     
    
    872
    -    def get_visible_buttons(self):
    
    886
    +    def get_visible_buttons(self) -> List[str]:
    
    873 887
             return ['back', self.get_toplevel().get_currenct_method()]
    
    874 888
     
    
    875
    -    def get_default_button(self):
    
    889
    +    def get_default_button(self) -> str:
    
    876 890
             return 'back'
    
    877 891
     
    
    878 892
     
    
    879 893
     class Form(Page):
    
    880
    -    def __init__(self):
    
    894
    +    def __init__(self) -> None:
    
    881 895
             Page.__init__(self)
    
    882 896
             self.set_valign(Gtk.Align.FILL)
    
    883 897
             self.complete = False
    
    884
    -        self.title = _('Create Account')
    
    898
    +        self.title: str = _('Create Account')
    
    885 899
             self._current_form = None
    
    886 900
     
    
    887 901
             heading = Gtk.Label(label=_('Create Account'))
    
    ... ... @@ -895,7 +909,7 @@ def __init__(self):
    895 909
             self.show_all()
    
    896 910
     
    
    897 911
         @property
    
    898
    -    def has_form(self):
    
    912
    +    def has_form(self) -> bool:
    
    899 913
             return self._current_form is not None
    
    900 914
     
    
    901 915
         def _on_is_valid(self, _widget, is_valid):
    
    ... ... @@ -913,14 +927,14 @@ def add_form(self, form):
    913 927
             self.pack_start(self._current_form, True, True, 0)
    
    914 928
             self._current_form.show_all()
    
    915 929
     
    
    916
    -    def get_credentials(self):
    
    930
    +    def get_credentials(self) -> Tuple[str, str]:
    
    917 931
             return (self._current_form.get_form()['username'].value,
    
    918 932
                     self._current_form.get_form()['password'].value)
    
    919 933
     
    
    920 934
         def get_submit_form(self):
    
    921 935
             return self._current_form.get_submit_form()
    
    922 936
     
    
    923
    -    def remove_form(self):
    
    937
    +    def remove_form(self) -> None:
    
    924 938
             if self._current_form is None:
    
    925 939
                 return
    
    926 940
     
    
    ... ... @@ -928,28 +942,28 @@ def remove_form(self):
    928 942
             self._current_form.destroy()
    
    929 943
             self._current_form = None
    
    930 944
     
    
    931
    -    def focus(self):
    
    945
    +    def focus(self) -> None:
    
    932 946
             self._current_form.focus_first_entry()
    
    933 947
     
    
    934
    -    def get_visible_buttons(self):
    
    948
    +    def get_visible_buttons(self) -> List[str]:
    
    935 949
             return ['back', 'signup']
    
    936 950
     
    
    937
    -    def get_default_button(self):
    
    951
    +    def get_default_button(self) -> str:
    
    938 952
             return 'signup'
    
    939 953
     
    
    940 954
     
    
    941 955
     class Redirect(Page):
    
    942
    -    def __init__(self):
    
    956
    +    def __init__(self) -> None:
    
    943 957
             Page.__init__(self)
    
    944
    -        self.title = _('Redirect')
    
    945
    -        self._link = None
    
    958
    +        self.title: str = _('Redirect')
    
    959
    +        self._link: Optional[str] = None
    
    946 960
     
    
    947 961
             self._ui = get_builder('account_wizard.ui')
    
    948 962
             self.pack_start(self._ui.redirect_box, True, True, 0)
    
    949 963
             self._ui.link_button.connect('clicked', self._on_link_button)
    
    950 964
             self.show_all()
    
    951 965
     
    
    952
    -    def set_redirect(self, link, instructions):
    
    966
    +    def set_redirect(self, link: str, instructions: str) -> None:
    
    953 967
             if instructions is None:
    
    954 968
                 instructions = _('Register on the Website')
    
    955 969
             self._ui.instructions.set_text(instructions)
    
    ... ... @@ -958,33 +972,33 @@ def set_redirect(self, link, instructions):
    958 972
         def _on_link_button(self, _button):
    
    959 973
             open_uri(self._link)
    
    960 974
     
    
    961
    -    def get_visible_buttons(self):
    
    975
    +    def get_visible_buttons(self) -> List[str]:
    
    962 976
             return ['back']
    
    963 977
     
    
    964 978
     
    
    965 979
     class Success(SuccessPage):
    
    966
    -    def __init__(self):
    
    980
    +    def __init__(self) -> None:
    
    967 981
             SuccessPage.__init__(self)
    
    968 982
             self.set_title(_('Account Added'))
    
    969 983
             self.set_heading(_('Account has been added successfully'))
    
    970 984
     
    
    971
    -        self._account = None
    
    985
    +        self._account: Optional[str] = None
    
    972 986
     
    
    973
    -    def set_account(self, account):
    
    987
    +    def set_account(self, account: str) -> None:
    
    974 988
             self._account = account
    
    975 989
     
    
    976 990
         @property
    
    977
    -    def account(self):
    
    991
    +    def account(self) -> Optional[str]:
    
    978 992
             return self._account
    
    979 993
     
    
    980
    -    def get_visible_buttons(self):
    
    994
    +    def get_visible_buttons(self) -> List[str]:
    
    981 995
             return ['connect']
    
    982 996
     
    
    983 997
     
    
    984 998
     class Error(ErrorPage):
    
    985
    -    def __init__(self):
    
    999
    +    def __init__(self) -> None:
    
    986 1000
             ErrorPage.__init__(self)
    
    987 1001
             self.set_heading(_('An error occurred during account creation'))
    
    988 1002
     
    
    989
    -    def get_visible_buttons(self):
    
    1003
    +    def get_visible_buttons(self) -> List[str]:
    
    990 1004
             return ['back']

  • gajim/gtk/groupchat_creation.py
    ... ... @@ -35,7 +35,7 @@
    35 35
     
    
    36 36
     
    
    37 37
     class CreateGroupchatWindow(Gtk.ApplicationWindow):
    
    38
    -    def __init__(self, account):
    
    38
    +    def __init__(self, account: str) -> None:
    
    39 39
             Gtk.ApplicationWindow.__init__(self)
    
    40 40
             self.set_name('CreateGroupchat')
    
    41 41
             self.set_application(app.app)
    
    ... ... @@ -49,7 +49,7 @@ def __init__(self, account):
    49 49
             self._ui = get_builder('groupchat_creation.ui')
    
    50 50
             self.add(self._ui.create_group_chat)
    
    51 51
     
    
    52
    -        self._destroyed = False
    
    52
    +        self._destroyed: bool = False
    
    53 53
     
    
    54 54
             self._account = self._fill_account_combo(account)
    
    55 55
     
    
    ... ... @@ -63,11 +63,11 @@ def __init__(self, account):
    63 63
             self.show_all()
    
    64 64
             self.set_focus(self._ui.address_entry)
    
    65 65
     
    
    66
    -    def _get_muc_service_jid(self):
    
    66
    +    def _get_muc_service_jid(self) -> str:
    
    67 67
             con = app.connections[self._account]
    
    68 68
             return str(con.get_module('MUC').service_jid or 'muc.example.com')
    
    69 69
     
    
    70
    -    def _fill_account_combo(self, account):
    
    70
    +    def _fill_account_combo(self, account: str) -> str:
    
    71 71
             accounts = app.get_enabled_accounts_with_labels(connected_only=True)
    
    72 72
             account_liststore = self._ui.account_combo.get_model()
    
    73 73
             for acc in accounts:
    
    ... ... @@ -84,7 +84,7 @@ def _fill_account_combo(self, account):
    84 84
             self._ui.account_combo.set_active_id(account)
    
    85 85
             return account
    
    86 86
     
    
    87
    -    def _create_entry_completion(self):
    
    87
    +    def _create_entry_completion(self) -> None:
    
    88 88
             entry_completion = Gtk.EntryCompletion()
    
    89 89
             model = Gtk.ListStore(str)
    
    90 90
             entry_completion.set_model(model)
    
    ... ... @@ -95,7 +95,7 @@ def _create_entry_completion(self):
    95 95
     
    
    96 96
             self._ui.address_entry.set_completion(entry_completion)
    
    97 97
     
    
    98
    -    def _fill_placeholders(self):
    
    98
    +    def _fill_placeholders(self) -> None:
    
    99 99
             placeholder = random.choice(MUC_CREATION_EXAMPLES)
    
    100 100
             server = self._get_muc_service_jid()
    
    101 101
     
    
    ... ... @@ -104,7 +104,7 @@ def _fill_placeholders(self):
    104 104
             self._ui.description_entry.set_placeholder_text(
    
    105 105
                 placeholder[1] + _(' (optional)...'))
    
    106 106
             self._ui.address_entry.set_placeholder_text(
    
    107
    -            '%s@%s' % (placeholder[2], server))
    
    107
    +            f'{placeholder[2]}@{server}')
    
    108 108
     
    
    109 109
         def _on_key_press_event(self, _widget, event):
    
    110 110
             if event.keyval == Gdk.KEY_Escape:
    
    ... ... @@ -123,9 +123,9 @@ def _update_entry_completion(self, entry, text):
    123 123
             model.clear()
    
    124 124
     
    
    125 125
             server = self._get_muc_service_jid()
    
    126
    -        model.append(['%s@%s' % (text, server)])
    
    126
    +        model.append([f'{text}@{server}'])
    
    127 127
     
    
    128
    -    def _validate_jid(self, text):
    
    128
    +    def _validate_jid(self, text: str) -> None:
    
    129 129
             if not text:
    
    130 130
                 self._set_warning_icon(False)
    
    131 131
                 self._ui.create_button.set_sensitive(False)
    
    ... ... @@ -142,7 +142,7 @@ def _validate_jid(self, text):
    142 142
                 self._set_warning_icon(False)
    
    143 143
                 self._ui.create_button.set_sensitive(True)
    
    144 144
     
    
    145
    -    def _set_processing_state(self, enabled):
    
    145
    +    def _set_processing_state(self, enabled: bool) -> None:
    
    146 146
             if enabled:
    
    147 147
                 self._ui.spinner.start()
    
    148 148
                 self._ui.create_button.set_sensitive(False)
    
    ... ... @@ -150,28 +150,28 @@ def _set_processing_state(self, enabled):
    150 150
                 self._ui.spinner.stop()
    
    151 151
             self._ui.grid.set_sensitive(not enabled)
    
    152 152
     
    
    153
    -    def _set_warning_icon(self, enabled):
    
    153
    +    def _set_warning_icon(self, enabled: bool) -> None:
    
    154 154
             icon = 'dialog-warning-symbolic' if enabled else None
    
    155 155
             self._ui.address_entry.set_icon_from_icon_name(
    
    156 156
                 Gtk.EntryIconPosition.SECONDARY, icon)
    
    157 157
     
    
    158
    -    def _set_warning_tooltip(self, text):
    
    158
    +    def _set_warning_tooltip(self, text: str) -> None:
    
    159 159
             self._ui.address_entry.set_icon_tooltip_text(
    
    160 160
                 Gtk.EntryIconPosition.SECONDARY, text)
    
    161 161
     
    
    162
    -    def _set_warning(self, text):
    
    162
    +    def _set_warning(self, text: str) -> None:
    
    163 163
             self._set_warning_icon(True)
    
    164 164
             self._set_warning_tooltip(text)
    
    165 165
             self._ui.create_button.set_sensitive(False)
    
    166 166
     
    
    167
    -    def _set_warning_from_error(self, error):
    
    167
    +    def _set_warning_from_error(self, error: StanzaError) -> None:
    
    168 168
             condition = error.condition
    
    169 169
             if condition == 'gone':
    
    170 170
                 condition = 'already-exists'
    
    171 171
             text = MUC_DISCO_ERRORS.get(condition, to_user_string(error))
    
    172 172
             self._set_warning(text)
    
    173 173
     
    
    174
    -    def _set_warning_from_error_code(self, error_code):
    
    174
    +    def _set_warning_from_error_code(self, error_code: str) -> None:
    
    175 175
             self._set_warning(MUC_DISCO_ERRORS[error_code])
    
    176 176
     
    
    177 177
         def _on_address_entry_changed(self, entry):
    
    ... ... @@ -212,7 +212,7 @@ def _disco_info_received(self, task):
    212 212
     
    
    213 213
             self._set_processing_state(False)
    
    214 214
     
    
    215
    -    def _create_muc(self, room_jid):
    
    215
    +    def _create_muc(self, room_jid: str) -> None:
    
    216 216
             name = self._ui.name_entry.get_text()
    
    217 217
             description = self._ui.description_entry.get_text()
    
    218 218
             is_public = self._ui.public_switch.get_active()
    

  • gajim/gtk/main.py
    ... ... @@ -222,7 +222,6 @@ def _on_action(self, action, _param):
    222 222
             control = self.get_active_control()
    
    223 223
             if control is None:
    
    224 224
                 return None
    
    225
    -
    
    226 225
             log.info('Activate action: %s, active control: %s',
    
    227 226
                      action.get_name(), control.contact.jid)
    
    228 227
     
    
    ... ... @@ -281,6 +280,8 @@ def _on_action(self, action, _param):
    281 280
                 self.select_chat_number(number)
    
    282 281
                 return None
    
    283 282
     
    
    283
    +        return None
    
    284
    +
    
    284 285
         def _on_window_motion_notify(self, _widget, _event):
    
    285 286
             control = self.get_active_control()
    
    286 287
             if control is None:
    

  • gajim/gtk/ssl_error_dialog.py
    ... ... @@ -12,11 +12,11 @@
    12 12
     # You should have received a copy of the GNU General Public License
    
    13 13
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    14 14
     
    
    15
    -
    
    16
    -from gi.repository import Gtk
    
    17 15
     from gi.repository import Gio
    
    16
    +from gi.repository import Gtk
    
    18 17
     
    
    19 18
     from gajim.common import app
    
    19
    +from gajim.common.client import Client
    
    20 20
     
    
    21 21
     from gajim.common.const import GIO_TLS_ERRORS
    
    22 22
     from gajim.common.i18n import _
    
    ... ... @@ -26,7 +26,12 @@
    26 26
     
    
    27 27
     
    
    28 28
     class SSLErrorDialog(Gtk.ApplicationWindow):
    
    29
    -    def __init__(self, account, client, cert, error):
    
    29
    +    def __init__(self,
    
    30
    +                 account: str,
    
    31
    +                 client: Client,
    
    32
    +                 cert: Gio.TlsCertificate,
    
    33
    +                 error: Gio.TlsCertificateFlags
    
    34
    +                 ) -> None:
    
    30 35
             Gtk.ApplicationWindow.__init__(self)
    
    31 36
             self.set_name('SSLErrorDialog')
    
    32 37
             self.set_application(app.app)
    
    ... ... @@ -50,7 +55,7 @@ def __init__(self, account, client, cert, error):
    50 55
             self._ui.connect_signals(self)
    
    51 56
             self.show_all()
    
    52 57
     
    
    53
    -    def _process_error(self):
    
    58
    +    def _process_error(self) -> None:
    
    54 59
             self._ui.intro_text.set_text(
    
    55 60
                 _('There was an error while attempting to verify the SSL '
    
    56 61
                   'certificate of your XMPP server (%s).') % self._server)
    

  • gajim/gui_interface.py
    ... ... @@ -31,6 +31,10 @@
    31 31
     # You should have received a copy of the GNU General Public License
    
    32 32
     # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    33 33
     
    
    34
    +from typing import Dict
    
    35
    +from typing import Optional
    
    36
    +from typing import Union
    
    37
    +
    
    34 38
     import os
    
    35 39
     import sys
    
    36 40
     import time
    
    ... ... @@ -72,6 +76,7 @@
    72 76
     from gajim.common.client import Client
    
    73 77
     from gajim.common.preview import PreviewManager
    
    74 78
     from gajim.common.const import Display
    
    79
    +from gajim.common.file_props import FileProp
    
    75 80
     
    
    76 81
     from gajim.common.connection_handlers_events import InformationEvent
    
    77 82
     
    
    ... ... @@ -123,7 +128,7 @@ def __init__(self):
    123 128
                 self.handle_event_file_progress,
    
    124 129
                 self.handle_event_file_error)
    
    125 130
     
    
    126
    -        self._last_ft_progress_update = 0
    
    131
    +        self._last_ft_progress_update: float = 0
    
    127 132
     
    
    128 133
             app.proxy65_manager = proxy65_manager.Proxy65Manager(app.idlequeue)
    
    129 134
     
    
    ... ... @@ -149,19 +154,19 @@ def __init__(self):
    149 154
     
    
    150 155
             self.instances = {}
    
    151 156
     
    
    152
    -        for a in app.connections:
    
    153
    -            self.instances[a] = {
    
    157
    +        for acc in app.connections:
    
    158
    +            self.instances[acc] = {
    
    154 159
                     'infos': {},
    
    155 160
                     'disco': {}
    
    156 161
                 }
    
    157
    -            app.contacts.add_account(a)
    
    158
    -            app.groups[a] = {}
    
    159
    -            app.gc_connected[a] = {}
    
    160
    -            app.automatic_rooms[a] = {}
    
    161
    -            app.newly_added[a] = []
    
    162
    -            app.to_be_removed[a] = []
    
    163
    -            app.nicks[a] = app.settings.get_account_setting(a, 'name')
    
    164
    -            app.block_signed_in_notifications[a] = True
    
    162
    +            app.contacts.add_account(acc)
    
    163
    +            app.groups[acc] = {}
    
    164
    +            app.gc_connected[acc] = {}
    
    165
    +            app.automatic_rooms[acc] = {}
    
    166
    +            app.newly_added[acc] = []
    
    167
    +            app.to_be_removed[acc] = []
    
    168
    +            app.nicks[acc] = app.settings.get_account_setting(acc, 'name')
    
    169
    +            app.block_signed_in_notifications[acc] = True
    
    165 170
     
    
    166 171
             if sys.platform not in ('win32', 'darwin'):
    
    167 172
                 logind.enable()
    
    ... ... @@ -172,7 +177,7 @@ def __init__(self):
    172 177
             idle.Monitor.set_interval(app.settings.get('autoawaytime') * 60,
    
    173 178
                                       app.settings.get('autoxatime') * 60)
    
    174 179
     
    
    175
    -        self.systray_enabled = False
    
    180
    +        self.systray_enabled: bool = False
    
    176 181
     
    
    177 182
             if not app.is_display(Display.WAYLAND):
    
    178 183
                 from gajim.gui.status_icon import StatusIcon
    
    ... ... @@ -185,10 +190,10 @@ def __init__(self):
    185 190
             self._network_monitor = Gio.NetworkMonitor.get_default()
    
    186 191
             self._network_monitor.connect('notify::network-available',
    
    187 192
                                           self._network_status_changed)
    
    188
    -        self._network_state = self._network_monitor.get_network_available()
    
    193
    +        self._network_state: bool = self._network_monitor.get_network_available()
    
    189 194
     
    
    190 195
         def _create_core_handlers_list(self):
    
    191
    -        # pyline: disable=line-too-long
    
    196
    +        # pylint: disable=line-too-long
    
    192 197
             self.handlers = {
    
    193 198
                 'information': [self.handle_event_information],
    
    194 199
                 'iq-error-received': [self.handle_event_iq_error],
    
    ... ... @@ -225,7 +230,7 @@ def _register_core_handlers(self):
    225 230
                         prio,
    
    226 231
                         event_handler)
    
    227 232
     
    
    228
    -    def handle_event(self, account, jid, notif_detail):
    
    233
    +    def handle_event(self, account: str, jid: str, notif_detail: str) -> None:
    
    229 234
             jid = JID.from_string(jid)
    
    230 235
     
    
    231 236
             if notif_detail in ('connection-lost', 'connection-failed'):
    
    ... ... @@ -423,7 +428,7 @@ def handle_event_status(self, event):
    423 428
                                          event.account)
    
    424 429
     
    
    425 430
         @staticmethod
    
    426
    -    def _unblock_signed_in_notifications(account):
    
    431
    +    def _unblock_signed_in_notifications(account: str) -> None:
    
    427 432
             app.block_signed_in_notifications[account] = False
    
    428 433
     
    
    429 434
         @staticmethod
    
    ... ... @@ -489,11 +494,14 @@ def handle_event_roster_item_exchange(event):
    489 494
     
    
    490 495
         # Jingle File Transfer
    
    491 496
         @staticmethod
    
    492
    -    def handle_event_file_error(title, message):
    
    497
    +    def handle_event_file_error(title: str, message: str) -> None:
    
    493 498
             # TODO: integrate this better
    
    494 499
             ErrorDialog(title, message)
    
    495 500
     
    
    496
    -    def handle_event_file_progress(self, _account, file_props):
    
    501
    +    def handle_event_file_progress(self,
    
    502
    +                                   _account: str,
    
    503
    +                                   file_props: FileProp
    
    504
    +                                   ) -> None:
    
    497 505
             if time.time() - self._last_ft_progress_update < 0.5:
    
    498 506
                 # Update progress every 500ms only
    
    499 507
                 return
    
    ... ... @@ -502,7 +510,10 @@ def handle_event_file_progress(self, _account, file_props):
    502 510
             app.nec.push_incoming_event(
    
    503 511
                 NetworkEvent('file-progress', file_props=file_props))
    
    504 512
     
    
    505
    -    def handle_event_file_rcv_completed(self, account, file_props):
    
    513
    +    def handle_event_file_rcv_completed(self,
    
    514
    +                                        account: str,
    
    515
    +                                        file_props: FileProp
    
    516
    +                                        ) -> None:
    
    506 517
             jid = JID.from_string(file_props.receiver)
    
    507 518
             if file_props.error != 0:
    
    508 519
                 self.instances['file_transfers'].set_status(file_props, 'stop')
    
    ... ... @@ -560,7 +571,8 @@ def handle_event_file_rcv_completed(self, account, file_props):
    560 571
                                      account=account,
    
    561 572
                                      jid=jid.bare))
    
    562 573
     
    
    563
    -    def __compare_hashes(self, account, file_props):
    
    574
    +    @staticmethod
    
    575
    +    def __compare_hashes(account: str, file_props: FileProp) -> None:
    
    564 576
             hashes = Hashes2()
    
    565 577
             try:
    
    566 578
                 file_ = open(file_props.file_name, 'rb')
    
    ... ... @@ -651,7 +663,11 @@ def _on_cancel_upload(self, transfer, _signal_name):
    651 663
             client = app.get_client(transfer.account)
    
    652 664
             client.get_module('HTTPUpload').cancel_transfer(transfer)
    
    653 665
     
    
    654
    -    def create_groupchat(self, account, room_jid, config):
    
    666
    +    @staticmethod
    
    667
    +    def create_groupchat(account: str,
    
    668
    +                         room_jid: str,
    
    669
    +                         config: Dict[str, Union[str, bool]]
    
    670
    +                         ) -> None:
    
    655 671
             if app.window.chat_exists(account, room_jid):
    
    656 672
                 log.error('Trying to create groupchat '
    
    657 673
                           'which is already added as chat')
    
    ... ... @@ -660,18 +676,27 @@ def create_groupchat(self, account, room_jid, config):
    660 676
             client = app.get_client(account)
    
    661 677
             client.get_module('MUC').create(room_jid, config)
    
    662 678
     
    
    663
    -    def show_add_join_groupchat(self, account, jid, nickname=None,
    
    664
    -                                password=None):
    
    665
    -        if not app.window.chat_exists(account, jid):
    
    679
    +    @staticmethod
    
    680
    +    def show_add_join_groupchat(account: str,
    
    681
    +                                jid: str,
    
    682
    +                                nickname: Optional[str] = None,
    
    683
    +                                password: Optional[str] = None
    
    684
    +                                ) -> None:
    
    685
    +        if not app.window.chat_exists(account, JID.from_string(jid)):
    
    666 686
                 client = app.get_client(account)
    
    667 687
                 client.get_module('MUC').join(
    
    668 688
                     jid, nick=nickname, password=password)
    
    669 689
     
    
    670 690
             app.window.add_group_chat(account, jid, select=True)
    
    671 691
     
    
    672
    -    def start_chat_from_jid(self, account, jid, message=None):
    
    692
    +    @staticmethod
    
    693
    +    def start_chat_from_jid(account: str,
    
    694
    +                            jid: str,
    
    695
    +                            message: Optional[str] = None
    
    696
    +                            ) -> None:
    
    697
    +        jid = JID.from_string(jid)
    
    673 698
             if app.window.chat_exists(account, jid):
    
    674
    -            app.window.select_chat(account, JID.from_string(jid))
    
    699
    +            app.window.select_chat(account, jid)
    
    675 700
                 if message is not None:
    
    676 701
                     control = app.window.get_control(account, jid)
    
    677 702
                     if control is None:
    
    ... ... @@ -680,7 +705,7 @@ def start_chat_from_jid(self, account, jid, message=None):
    680 705
                 return
    
    681 706
     
    
    682 707
             # TODO: handle message arg in StartChat
    
    683
    -        app.app.activate_action('start-chat', GLib.Variant('s', jid))
    
    708
    +        app.app.activate_action('start-chat', GLib.Variant('s', str(jid)))
    
    684 709
     
    
    685 710
         @staticmethod
    
    686 711
         def _on_muc_added(event):
    
    ... ... @@ -690,13 +715,14 @@ def _on_muc_added(event):
    690 715
             app.window.add_group_chat(event.account, event.jid)
    
    691 716
     
    
    692 717
         @staticmethod
    
    693
    -    def create_account(account,
    
    694
    -                       username,
    
    695
    -                       domain,
    
    696
    -                       password,
    
    697
    -                       proxy_name,
    
    698
    -                       custom_host,
    
    699
    -                       anonymous=False):
    
    718
    +    def create_account(account: str,
    
    719
    +                       username: str,
    
    720
    +                       domain: str,
    
    721
    +                       password: str,
    
    722
    +                       proxy_name: str,
    
    723
    +                       custom_host: str,
    
    724
    +                       anonymous:bool = False
    
    725
    +                       ) -> None:
    
    700 726
     
    
    701 727
             account_label = f'{username}@{domain}'
    
    702 728
             if anonymous:
    
    ... ... @@ -706,10 +732,9 @@ def create_account(account,
    706 732
             config = {}
    
    707 733
             config['active'] = False
    
    708 734
             config['name'] = username
    
    709
    -        config['resource'] = 'gajim.%s' % helpers.get_random_string(8)
    
    735
    +        config['resource'] = f'gajim.{helpers.get_random_string(8)}'
    
    710 736
             config['account_label'] = account_label
    
    711
    -        config['account_color'] = get_color_for_account(
    
    712
    -            '%s@%s' % (username, domain))
    
    737
    +        config['account_color'] = get_color_for_account(f'{username}@{domain}')
    
    713 738
             config['hostname'] = domain
    
    714 739
             config['savepass'] = True
    
    715 740
             config['anonymous_auth'] = anonymous
    
    ... ... @@ -744,7 +769,7 @@ def create_account(account,
    744 769
             if window is not None:
    
    745 770
                 window.add_account(account)
    
    746 771
     
    
    747
    -    def enable_account(self, account):
    
    772
    +    def enable_account(self, account: str) -> None:
    
    748 773
             if account == app.ZEROCONF_ACC_NAME:
    
    749 774
                 app.connections[account] = connection_zeroconf.ConnectionZeroconf(
    
    750 775
                     account)
    
    ... ... @@ -789,7 +814,7 @@ def enable_account(self, account):
    789 814
             if window is not None:
    
    790 815
                 GLib.idle_add(window.enable_account, account, True)
    
    791 816
     
    
    792
    -    def disable_account(self, account):
    
    817
    +    def disable_account(self, account: str) -> None:
    
    793 818
             for win in get_app_windows(account):
    
    794 819
                 # Close all account specific windows, except the RemoveAccount
    
    795 820
                 # dialog. It shows if the removal was successful.
    
    ... ... @@ -820,7 +845,7 @@ def disable_account(self, account):
    820 845
             del app.to_be_removed[account]
    
    821 846
             del app.newly_added[account]
    
    822 847
     
    
    823
    -    def remove_account(self, account):
    
    848
    +    def remove_account(self, account: str) -> None:
    
    824 849
             if app.settings.get_account_setting(account, 'active'):
    
    825 850
                 self.disable_account(account)
    
    826 851
     
    
    ... ... @@ -835,7 +860,7 @@ def remove_account(self, account):
    835 860
             if window is not None:
    
    836 861
                 window.remove_account(account)
    
    837 862
     
    
    838
    -    def autoconnect(self):
    
    863
    +    def autoconnect(self) -> None:
    
    839 864
             """
    
    840 865
             Auto connect at startup
    
    841 866
             """
    
    ... ... @@ -856,7 +881,10 @@ def autoconnect(self):
    856 881
     
    
    857 882
                 app.connections[account].change_status(status, status_message)
    
    858 883
     
    
    859
    -    def change_status(self, status, account=None):
    
    884
    +    def change_status(self,
    
    885
    +                      status: str,
    
    886
    +                      account: Optional[str] = None
    
    887
    +                      ) -> None:
    
    860 888
             ask = ask_for_status_message(status)
    
    861 889
     
    
    862 890
             if status is None:
    
    ... ... @@ -880,7 +908,7 @@ def change_status(self, status, account=None):
    880 908
     
    
    881 909
                 self._change_status(acc, status)
    
    882 910
     
    
    883
    -    def change_account_status(self, account, status):
    
    911
    +    def change_account_status(self, account: str, status: str) -> None:
    
    884 912
             ask = ask_for_status_message(status)
    
    885 913
     
    
    886 914
             client = app.get_client(account)
    
    ... ... @@ -894,7 +922,7 @@ def change_account_status(self, account, status):
    894 922
             self._change_status(account, status)
    
    895 923
     
    
    896 924
         @staticmethod
    
    897
    -    def _change_status(account, status):
    
    925
    +    def _change_status(account: str, status: str) -> None:
    
    898 926
             client = app.get_client(account)
    
    899 927
             message = client.status_message
    
    900 928
             if status != 'offline':
    
    ... ... @@ -911,17 +939,17 @@ def _change_status(account, status):
    911 939
     
    
    912 940
             client.change_status(status, message)
    
    913 941
     
    
    914
    -    def show_systray(self):
    
    942
    +    def show_systray(self) -> None:
    
    915 943
             if not app.is_display(Display.WAYLAND):
    
    916 944
                 self.systray_enabled = True
    
    917 945
                 self.systray.show_icon()
    
    918 946
     
    
    919
    -    def hide_systray(self):
    
    947
    +    def hide_systray(self) -> None:
    
    920 948
             if not app.is_display(Display.WAYLAND):
    
    921 949
                 self.systray_enabled = False
    
    922 950
                 self.systray.hide_icon()
    
    923 951
     
    
    924
    -    def process_connections(self):
    
    952
    +    def process_connections(self) -> bool:
    
    925 953
             """
    
    926 954
             Called each foo (200) milliseconds. Check for idlequeue timeouts
    
    927 955
             """
    
    ... ... @@ -949,10 +977,10 @@ def process_connections(self):
    949 977
             return True  # renew timeout (loop for ever)
    
    950 978
     
    
    951 979
         @staticmethod
    
    952
    -    def save_config():
    
    980
    +    def save_config() -> None:
    
    953 981
             app.settings.save()
    
    954 982
     
    
    955
    -    def save_avatar(self, data):
    
    983
    +    def save_avatar(self, data: bytes) -> Optional[str]:
    
    956 984
             return self.avatar_storage.save_avatar(data)
    
    957 985
     
    
    958 986
         def get_avatar(self,
    
    ... ... @@ -968,11 +996,11 @@ def get_avatar(self,
    968 996
             return self.avatar_storage.get_surface(
    
    969 997
                 contact, size, scale, show, style=style)
    
    970 998
     
    
    971
    -    def avatar_exists(self, filename):
    
    999
    +    def avatar_exists(self, filename: str) -> bool:
    
    972 1000
             return self.avatar_storage.get_avatar_path(filename) is not None
    
    973 1001
     
    
    974 1002
         @staticmethod
    
    975
    -    def create_ipython_window():
    
    1003
    +    def create_ipython_window() -> None:
    
    976 1004
             # Check if IPython is installed
    
    977 1005
             ipython = find_spec('IPython')
    
    978 1006
             is_installed = ipython is not None
    
    ... ... @@ -1027,7 +1055,7 @@ def _network_status_changed(self, monitor, _param):
    1027 1055
                             connection.state.is_available):
    
    1028 1056
                         connection.disconnect(gracefully=False, reconnect=True)
    
    1029 1057
     
    
    1030
    -    def create_zeroconf_default_config(self):
    
    1058
    +    def create_zeroconf_default_config(self) -> None:
    
    1031 1059
             if app.settings.get_account_setting(app.ZEROCONF_ACC_NAME, 'name'):
    
    1032 1060
                 return
    
    1033 1061
             log.info('Creating zeroconf account')
    
    ... ... @@ -1057,7 +1085,7 @@ def create_zeroconf_default_config(self):
    1057 1085
                                              'active',
    
    1058 1086
                                              False)
    
    1059 1087
     
    
    1060
    -    def check_for_updates(self):
    
    1088
    +    def check_for_updates(self) -> None:
    
    1061 1089
             if not app.settings.get('check_for_update'):
    
    1062 1090
                 return
    
    1063 1091
     
    
    ... ... @@ -1073,10 +1101,10 @@ def check_for_updates(self):
    1073 1101
     
    
    1074 1102
             self.get_latest_release()
    
    1075 1103
     
    
    1076
    -    def get_latest_release(self):
    
    1104
    +    def get_latest_release(self) -> None:
    
    1077 1105
             log.info('Checking for Gajim updates')
    
    1078 1106
             session = Soup.Session()
    
    1079
    -        session.props.user_agent = 'Gajim %s' % app.version
    
    1107
    +        session.props.user_agent = f'Gajim {app.version}'
    
    1080 1108
             message = Soup.Message.new(
    
    1081 1109
                 'GET', 'https://gajim.org/current-version.json')
    
    1082 1110
             session.queue_message(message, self._on_update_checked)