Opened 8 years ago

Closed 7 years ago

#4412 closed enhancement (fixed)

A few pylint fixes

Reported by: thorstenp Owned by:
Priority: normal Milestone: 0.13
Component: None Version: hg
Severity: normal Keywords:
Cc: Blocked By:
Blocking: OS: All

Description

These are fixes for things discovered with the pylint tool. Gajim's functionality should be unchanged. The patches are against svn r10523.


001_pylint_W0106_remove_unnecessary_semicolons.patch

Rationale: Semicolons are fortunately not needed in python ;)


002_pylint_W0104_fix_statements_without_effect.patch

Removes some statements without effect. This should not have any effect :)


003_pylint_W0107_remove_unnecessary_pass_statements.patch

Removes some pass statements, which are preceded by other statements


004_pylint_W0101_fix_unreachable_code.patch

Removes / comments out some code after exceptions or return statements


005_pylint_E0102_fix_redefined_functions.patch

Removes a duplicate function in client_zeroconf.py


006_pylint_W0105_fix_string_statements_without_effect.patch

Fixes some module docstrings, which were not at the top of the module. Replaces unused strings with comments

Rationale: Uses less memory


007_pylint_W0611_remove_unused_imports.patch

Removes unnessecary imports.


008_pylint_E0602_fix_undefined_variables.patch

Fixes some typos, missing imports, not correctly prefixed statements, ...


009_pylint_W0602_fix_globals.patch

Removes some global statements, if the global is not getting assigned to.


010_pylint_W0612_fix_unused_variables.patch

Removes all assignments to variables, which do not get used later on. I.e. unsused exception variables, unused variables from tuple unpacking, ... Adds some missing global statements. Also some reimplementations, mostly list comprehensions which do not use the loop variable.

Rationale: Cleaner namespace, saves some cpu cycles.


011_pylint_W0622_fix_redefinded_builtins.patch

Replaces all redefined builtin symbols by builtin_.

Rationale: Maybe the most controversial change. Maybe it's ok in small functions to redefine builtins. I have decided to remove all redefinitions. Maybe a convention would be useful. I.e. iter -> iterator, list -> lst or something else, or the variables could be named after their content, and not their type.


012_pylint_W0631_fix_possibly_undefined_loop_variables.patch

Fixes the usage of loop variables outside of the loop. Contains reimplementations of the rfc2782 server selection mechanism and the function helpers.py:is_in_path. I did not know how to fix rosterwindow:2660: contact is always the last contact.

Rationale: I think it can be quite confusing to rely on this 'feature'.


013_pylint_E0203_fix_access_to_members_before_definition.patch

Adds some members which could be accessed before their definition.


014_pylint_E0213_add_self_as_first_argument_of_methods.patch

Adds one missing "self"


015_pylint_W0402_fix_deprecated_uses_of_the_string_module.patch

Removes one case of using the "split function" instead of the "split method"


016_pylint_W0404_fix_reimported_modules.patch

Removes some imports of already imported modules


017_pylint_W1010_fix_exceptions_not_inheriting_from_exception.patch

Rationale: Forbidden under Python 3


018_pylint_W0701_fix_string_exceptions.patch

Rationale: String exceptions have been removed from Python 3


019_pylint_W0702_fix_empty_except_clauses.patch

Remove the remaining empty except clauses.


020_pylint_W0311_fix_bad_indentation.patch

Some inconsistent indentations fixed


021_pylint_W0331_fix_unequal_operator.patch

Fix one remaining use of the "<>" operator


022_pylint_C0321_fix_more_than_one_statement_on_a_single_line.patch

Allow only one statement per line.

Rationale: Readablity counts.


diffstat:

 advanced.py                                     |   44 +-
 cell_renderer_image.py                          |   12 
 chat_control.py                                 |  224 ++++++-------
 common/GnuPG.py                                 |   37 +-
 common/GnuPGInterface.py                        |   35 +-
 common/atom.py                                  |    6 
 common/caps.py                                  |   27 -
 common/check_paths.py                           |    1 
 common/commands.py                              |   14 
 common/config.py                                |   36 +-
 common/connection.py                            |  100 +++---
 common/connection_handlers.py                   |  204 ++++++------
 common/dataforms.py                             |   61 ++-
 common/defs.py                                  |    2 
 common/gajim.py                                 |   11 
 common/helpers.py                               |   49 +--
 common/logger.py                                |   18 -
 common/nslookup.py                              |    3 
 common/optparser.py                             |   14 
 common/passwords.py                             |    2 
 common/pep.py                                   |    8 
 common/proxy65_manager.py                       |   13 
 common/pubsub.py                                |   18 -
 common/rst_xhtml_generator.py                   |    2 
 common/sleepy.py                                |    1 
 common/socks5.py                                |   31 -
 common/stanza_session.py                        |   28 -
 common/xmpp/auth.py                             |  114 ++++---
 common/xmpp/auth_nb.py                          |   65 ++--
 common/xmpp/browser.py                          |   67 ++--
 common/xmpp/c14n.py                             |    5 
 common/xmpp/client.py                           |  138 +++++---
 common/xmpp/client_nb.py                        |    8 
 common/xmpp/commands.py                         |   38 +-
 common/xmpp/debug.py                            |  103 +++---
 common/xmpp/dispatcher.py                       |  160 ++++++---
 common/xmpp/dispatcher_nb.py                    |   49 +--
 common/xmpp/features.py                         |  138 +++++---
 common/xmpp/features_nb.py                      |   49 +--
 common/xmpp/filetransfer.py                     |  126 ++++---
 common/xmpp/idlequeue.py                        |    3 
 common/xmpp/protocol.py                         |  301 ++++++++++++------
 common/xmpp/roster.py                           |   62 ++-
 common/xmpp/session.py                          |  113 ++++--
 common/xmpp/simplexml.py                        |  209 ++++++++----
 common/xmpp/transports.py                       |   86 +++--
 common/xmpp/transports_nb.py                    |   91 +++--
 common/zeroconf/client_zeroconf.py              |   46 +-
 common/zeroconf/connection_handlers_zeroconf.py |   35 +-
 common/zeroconf/roster_zeroconf.py              |    5 
 common/zeroconf/zeroconf.py                     |    6 
 common/zeroconf/zeroconf_avahi.py               |    4 
 common/zeroconf/zeroconf_bonjour.py             |   18 -
 config.py                                       |  388 +++++++++++-------------
 conversation_textview.py                        |  323 ++++++++++---------
 dataforms_widget.py                             |   38 +-
 dialogs.py                                      |  227 ++++++--------
 disco.py                                        |  229 +++++++-------
 features_window.py                              |   14 
 filetransfers_window.py                         |   79 ++--
 gajim-remote.py                                 |   56 +--
 gajim.py                                        |   66 +---
 gajim_themes_window.py                          |   42 +-
 groupchat_control.py                            |  244 ++++++---------
 groups.py                                       |    6 
 gtkexcepthook.py                                |    4 
 gtkgui_helpers.py                               |   33 --
 history_manager.py                              |    7 
 history_window.py                               |    4 
 htmltextview.py                                 |  175 +++++-----
 ipython_view.py                                 |   30 -
 lastfm.py                                       |   18 -
 message_control.py                              |    1 
 message_textview.py                             |    6 
 message_window.py                               |   42 +-
 music_track_listener.py                         |    1 
 negotiation.py                                  |    2 
 notify.py                                       |    8 
 osx/growl/Growl.py                              |    8 
 osx/growler.py                                  |    7 
 osx/syncmenu/setup.py                           |    3 
 osx/syncmenu/test-menu.py                       |    3 
 profile_window.py                               |    6 
 remote_control.py                               |    6 
 roster_window.py                                |  179 ++++-------
 search_window.py                                |   18 -
 secrets.py                                      |    1 
 tooltips.py                                     |   66 ++--
 vcard.py                                        |   11 
 89 files changed, 2877 insertions(+), 2514 deletions(-)

Attachments (1)

patches-98d4da301162.zip (124.9 KB) - added by thorstenp 8 years ago.
pylint fixes

Download all attachments as: .zip

Change History (10)

Changed 8 years ago by thorstenp

pylint fixes

comment:1 in reply to: ↑ description Changed 8 years ago by thorstenp

Corrected an error where 'type' got replaced by 'type_'. Added more patches, mostly concerning formatting. Patches are here:

http://nobody27182.dyndns.org/~tp/gajim_patches.zip

comment:2 in reply to: ↑ description Changed 8 years ago by thorstenp

Replying to thorstenp:

The patch repository is here now:

http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi

comment:3 follow-up: Changed 8 years ago by asterix

we'll wait 0.12 release to apply them, they introduce some bugs (right click don't work anymore in roster, zeroconf don't work anymore, ...)

comment:4 in reply to: ↑ 3 ; follow-up: Changed 8 years ago by thorstenp

Replying to asterix:

we'll wait 0.12 release to apply them, they introduce some bugs (right click don't work anymore in roster, zeroconf don't work anymore, ...)

Bugs are fixed now. Mostly a, b = c[0] + c[1] instead of a, b = c[0], c[1]. It should work now.

Changes are here:

http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi/gajim-upstream/.hg/patches/rev/3473d5850a7e

Repolink:

http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi/gajim-upstream/.hg/patches/

comment:5 in reply to: ↑ 4 Changed 8 years ago by anonymous

Replying to thorstenp:

Replying to asterix:

we'll wait 0.12 release to apply them, they introduce some bugs (right click don't work anymore in roster, zeroconf don't work anymore, ...)

Bugs are fixed now. Mostly a, b = c[0] + c[1] instead of a, b = c[0], c[1]. It should work now.

Changes are here:

http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi/gajim-upstream/.hg/patches/rev/3473d5850a7e

Repolink:

http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi/gajim-upstream/.hg/patches/

Patches are still against svn [97d67874faa5471656ee621a20416e5999945b6d].

comment:6 in reply to: ↑ description Changed 8 years ago by thorstenp

Replying to thorstenp:

I have fixed one zeroconf_bonjour issue.

I am going to sync the patches every now and then with gajim svn. So you can pull anytime you want. So far the patches seem stable for me, but as always ymmv. If somebody wants to try this branch, then get mercurial and do:

hg qclone http://nobody27182.dyndns.org/~tp/gajim/hgwebdir.cgi/gajim-upstream
cd gajim-upstream
hg qpush --all
cd src
python gajim.py

Reported ;) bugs concerning this branch will get fixed.

comment:7 Changed 7 years ago by thorstenp

Hi!

I have updated the patches to svn [94d292b8f7364d7f092dea61d979812a27e97adf]. Additionally I have removed the 2to3 patches, which affect mostly formatting, as they can be semi-automatically regenerated at any time. The remaining patches are not very intrusive.

comment:8 Changed 7 years ago by asterix

ha .. I started to include some this morning, I'll continue in the next days

comment:9 Changed 7 years ago by asterix

  • Milestone set to 0.13
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.