Philipp Hörist pushed to branch master at gajim / gajim
Commits: e808b73b by lovetox at 2022-06-19T12:52:39+02:00 chore: Fix pylint errors
- - - - - 666d92df by lovetox at 2022-06-19T12:52:39+02:00 ci: Update pylint checks
- - - - - a9d9c7dd by lovetox at 2022-06-19T12:53:58+02:00 chore: Remove unused file
- - - - -
12 changed files:
- .ci/pylint.sh - gajim/command_system/framework.py - gajim/common/app.py - gajim/common/i18n.py - gajim/common/idle.py - gajim/common/proxy65_manager.py - gajim/common/socks5.py - gajim/gtk/chat_list.py - gajim/gtk/search_view.py - gajim/gtk/xml_console.py - − mypy.ini - pylintrc
Changes:
===================================== .ci/pylint.sh ===================================== @@ -5,86 +5,20 @@ set -e
PYLINT=${PYLINT:-pylint}
-# Errors which are covered by pyright -# -# E1101 no-member -# E1102 not-callable -# E1111 assignment-from-no-return -# E1120 no-value-for-parameter -# E1121 too-many-function-args -# E1123 unexpected-keyword-arg -# E1124 redundant-keyword-arg -# E1125 missing-kwoa -# E1126 invalid-sequence-index -# E1127 invalid-slice-index -# E1128 assignment-from-none -# E1129 not-context-manager -# E1130 invalid-unary-operand-type -# E1131 unsupported-binary-operation -# E1132 repeated-keyword -# E1133 not-an-iterable -# E1134 not-a-mapping -# E1135 unsupported-membership-test -# E1136 unsubscriptable-object -# E1137 unsupported-assignment-operation -# E1138 unsupported-delete-operation -# E1139 invalid-metaclass -# E1140 unhashable-dict-key -# E1141 dict-iter-missing-items -# E1142 await-outside-async -# I1101 c-extension-no-member -# W0212 protected-access -# W1113 keyword-arg-before-vararg -# W1114 arguments-out-of-order -# W1115 non-str-assignment-to-dunder-name -# W1116 isinstance-second-argument-not-valid-type - -IGNORE_FLAKE8='C0301,W0611' - -IGNORE_PYRIGHT='E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1140,E1141,E1142,I1101,W0212,W1113,W1114,W1115,W1116' - -IGNORE_ALWAYS='R0801,C0209,W0237,W0707,R1732,W1404,W1406,R1725' - -IGNORE_ERRORS=C0103,C0302,C0301,C0330,C0411,C0415,E0401,E0611,R0201,R0901,R0904,R0912,R0913,R0914,R0915,R0916,R1702,R1710,W0201,W0221,W0223,W0231,W0233,W0603,W0613 - -IGNORE_GTK_MODULE_ERRORS=C0103,C0301,C0330,C0415,E0401,E0611,R0201,R0904,R0915,R1710,W0201,W0233,W0221,W0613 - -"$PYLINT" --version - -"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_FLAKE8,$IGNORE_ERRORS" --ignore=modules,dbus,gtk "$@" -"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_FLAKE8,$IGNORE_GTK_MODULE_ERRORS" "$@/gtk" -"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_FLAKE8,E0401,C0415" "$@/common/modules" -"$PYLINT" --disable="$IGNORE_PYRIGHT,$IGNORE_ALWAYS,$IGNORE_FLAKE8," "$@/common/dbus" +# Ignore but need fixing
# C0103 invalid-name -# C0209 use-f-string -# C0301 line-too-long -# C0302 too-many-lines -# C0330 bad-continuation # C0415 import-outside-toplevel -# E0401 import-error -# E0611 no-name-in-module -# R0201 no-self-use -# R0801 duplicat-code -# R0901 too-many-ancestors -# R0904 too-many-public-methods -# R0913 too-many-arguments -# R0912 too-many-branches -# R0914 too-many-locals -# R0915 too-many-statements -# R0916 too-many-boolean-expressions -# R1702 too-many-nested-blocks # R1710 inconsistent-return-statements -# R1732 consider-using-with -# R1725 super-with-arguments # W0201 attribute-defined-outside-init # W0221 arguments-differ -# W0223 abstract-method -# W0231 super-init-not-called # W0233 non-parent-init-called -# W0237 arguments-renamed -# W0603 global-statement # W0613 unused-argument -# W0707 raise-missing-from -# W1404 implicit-str-concat -# W1406 redundant-u-string-prefix + +NEED_FIXING=C0103,C0415,R1710,W0201,W0221,W0233,W0613 + + +"$PYLINT" --version +"$PYLINT" --disable="$NEED_FIXING" --ignore=modules,dbus "$@" +"$PYLINT" --disable="C0415" "$@/common/modules" +"$PYLINT" "$@/common/dbus"
===================================== gajim/command_system/framework.py ===================================== @@ -149,7 +149,7 @@ def get_command(self, name): def list_commands(self): commands = list_commands(self.COMMAND_HOST) commands = dict(commands) - return sorted(set(commands.values()), key=lambda k: k.__repr__()) + return sorted(set(commands.values()), key=repr)
class Command:
===================================== gajim/common/app.py ===================================== @@ -233,7 +233,7 @@ def detect_dependencies() -> None: try: gi.require_version('GUPnPIgd', '1.0') from gi.repository import GUPnPIgd - global gupnp_igd + global gupnp_igd # pylint: disable=global-statement gupnp_igd = GUPnPIgd.SimpleIgd() _dependencies['UPNP'] = True except ValueError: @@ -251,7 +251,7 @@ def detect_dependencies() -> None: try: gi.require_version('GSound', '1.0') from gi.repository import GSound - global gsound_ctx + global gsound_ctx # pylint: disable=global-statement gsound_ctx = GSound.Context() try: gsound_ctx.init() @@ -583,7 +583,7 @@ def prefers_app_menu() -> bool:
def load_css_config() -> None: - global css_config + global css_config # pylint: disable=global-statement from gajim.gui.css_config import CSSConfig css_config = CSSConfig()
===================================== gajim/common/i18n.py ===================================== @@ -111,7 +111,7 @@ def get_short_lang_code(lang: Optional[str] = None) -> str: def initialize_direction_mark() -> None: from gi.repository import Gtk
- global direction_mark + global direction_mark # pylint: disable=global-statement
if Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL: direction_mark = '\u200F'
===================================== gajim/common/idle.py ===================================== @@ -218,6 +218,7 @@ def set_extended_away(self, state: bool) -> None:
class Windows(IdleMonitor): def __init__(self) -> None: + IdleMonitor.__init__(self) self.OpenInputDesktop = ctypes.windll.user32.OpenInputDesktop self.CloseDesktop = ctypes.windll.user32.CloseDesktop self.SystemParametersInfo = ctypes.windll.user32.SystemParametersInfoW
===================================== gajim/common/proxy65_manager.py ===================================== @@ -261,6 +261,7 @@ def __init__(self,
Calls on_success, or on_failure according to the result. """ + IdleObject.__init__(self) self.host = host self.port = port self.jid = jid @@ -389,6 +390,7 @@ def __init__(self,
Call on_success, or on_failure according to the result. """ + IdleObject.__init__(self) self.host = host self.port = port self.jid = jid
===================================== gajim/common/socks5.py ===================================== @@ -341,7 +341,7 @@ def isHashInSockObjs(self, sockobjs, hash_): return False
def on_connection_accepted(self, sock, listener): - sock_hash = sock.__hash__() + sock_hash = hash(sock) if listener.file_props.type_ == 's' and \ not self.isHashInSockObjs(self.senders, sock_hash): sockobj = Socks5SenderServer(self.idlequeue, sock_hash, self, @@ -944,6 +944,7 @@ class Socks5Sender(IdleObject): """ def __init__(self, idlequeue, sock_hash, parent, _sock, host=None, port=None, fingerprint=None, connected=True, file_props=None): + IdleObject.__init__(self) self.fingerprint = fingerprint self.queue_idx = sock_hash self.queue = parent @@ -1028,6 +1029,7 @@ def __init__(self, idlequeue, streamhost, sid, file_props=None, fingerprint: fingerprint of certificates we shall use, set to None if TLS connection not desired """ + IdleObject.__init__(self) self.queue_idx = -1 self.streamhost = streamhost self.queue = None @@ -1407,6 +1409,7 @@ def __init__(self, idlequeue, port, fp, fingerprint=None): fingerprint: fingerprint of certificates we shall use, set to None if TLS connection not desired """ + IdleObject.__init__(self) self.port = port self.ais = socket.getaddrinfo(None, port, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_PASSIVE)
===================================== gajim/gtk/chat_list.py ===================================== @@ -108,7 +108,7 @@ def workspace_id(self) -> str: return self._workspace_id
def get_unread_count(self) -> int: - return sum([chats.unread_count for chats in self._chats.values()]) + return sum(chats.unread_count for chats in self._chats.values())
def get_chat_unread_count(self, account: str,
===================================== gajim/gtk/search_view.py ===================================== @@ -127,8 +127,8 @@ def _on_search(self, entry: Gtk.Entry) -> None: text, before_filters = self._strip_filters(text, 'before') if before_filters is not None: try: - before_filters = min([datetime.fromisoformat(date) for - date in before_filters]) + before_filters = min(datetime.fromisoformat(date) for + date in before_filters) except ValueError: self._ui.date_hint.show() return @@ -137,8 +137,8 @@ def _on_search(self, entry: Gtk.Entry) -> None: text, after_filters = self._strip_filters(text, 'after') if after_filters is not None: try: - after_filters = min([datetime.fromisoformat(date) for - date in after_filters]) + after_filters = min(datetime.fromisoformat(date) for + date in after_filters) # if only the day is specified, we want to look after the # end of that day. # if precision is increased,we do want to look during the
===================================== gajim/gtk/xml_console.py ===================================== @@ -415,6 +415,7 @@ def _print_stanza(self,
stanza = event.stanza if not isinstance(stanza, str): + # pylint: disable=unnecessary-dunder-call stanza = stanza.__str__(fancy=True)
if not stanza:
===================================== mypy.ini deleted ===================================== @@ -1,65 +0,0 @@ -[mypy] -python_version = 3.9 -warn_unused_configs = True -disallow_incomplete_defs = True -allow_redefinition = True - -[mypy-dbus.*] -ignore_missing_imports = True - -[mypy-win32file.*] -ignore_missing_imports = True - -[mypy-win32con.*] -ignore_missing_imports = True - -[mypy-pywintypes.*] -ignore_missing_imports = True - -[mypy-OpenSSL.*] -ignore_missing_imports = True - -[mypy-encodings.*] -ignore_missing_imports = True - -[mypy-precis_i18n.*] -ignore_missing_imports = True - -[mypy-winsound.*] -ignore_missing_imports = True - -[mypy-PIL.*] -ignore_missing_imports = True - -[mypy-netifaces.*] -ignore_missing_imports = True - -[mypy-keyring.*] -ignore_missing_imports = True - -[mypy-ossaudiodev.*] -ignore_missing_imports = True - -[mypy-css_parser.*] -ignore_missing_imports = True - -[mypy-distro.*] -ignore_missing_imports = True - -[mypy-IPython.*] -ignore_missing_imports = True - -[mypy-traitlets.*] -ignore_missing_imports = True - -[mypy-pygments.*] -ignore_missing_imports = True - -[mypy-cairo.*] -ignore_missing_imports = True - -[mypy-packaging.version.*] -ignore_missing_imports = True - -[mypy-gajim.gui.*] -ignore_missing_imports = True
===================================== pylintrc ===================================== @@ -7,7 +7,7 @@ extension-pkg-whitelist=
# Add files or directories to the blacklist. They should be base names, not # paths. -ignore=CVS +ignore=gui
# Add files or directories matching the regex patterns to the blacklist. The # regex matches against base names, not paths. @@ -50,12 +50,70 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" +# +# Errors which are covered by pyright +# +# E0401 import-error +# E1101 no-member +# E1102 not-callable +# E1111 assignment-from-no-return +# E1120 no-value-for-parameter +# E1121 too-many-function-args +# E1123 unexpected-keyword-arg +# E1124 redundant-keyword-arg +# E1125 missing-kwoa +# E1126 invalid-sequence-index +# E1127 invalid-slice-index +# E1128 assignment-from-none +# E1129 not-context-manager +# E1130 invalid-unary-operand-type +# E1131 unsupported-binary-operation +# E1132 repeated-keyword +# E1133 not-an-iterable +# E1134 not-a-mapping +# E1135 unsupported-membership-test +# E1136 unsubscriptable-object +# E1137 unsupported-assignment-operation +# E1138 unsupported-delete-operation +# E1139 invalid-metaclass +# E1140 unhashable-dict-key +# E1141 dict-iter-missing-items +# E1142 await-outside-async +# I1101 c-extension-no-member +# W0212 protected-access +# W1113 keyword-arg-before-vararg +# W1114 arguments-out-of-order +# W1115 non-str-assignment-to-dunder-name +# W1116 isinstance-second-argument-not-valid-type +# +# Errors which are covered by flake8 +# +# C0301 line-too-long +# C0303 trailing-whitespace +# C0304 missing-final-newline +# C0321 multiple-statements +# W0301 unnecessary-semicolon +# W0311 bad-indentation +# W0611 unused-import +# +# Ignore Always, we don’t need these checks # -# Most errors here are disabled because they are covered by pyright # C0111 missing-docstring +# C0209 use-f-string +# C0302 too-many-lines +# R0801 duplicat-code +# R0904 too-many-public-methods +# R0913 too-many-arguments +# R0915 too-many-statements +# R1725 super-with-arguments +# R1732 consider-using-with +# W0237 arguments-renamed # W0511 fix-me -# -disable=C0111,W0511,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1140,E1141,E1142,I1101,W0212,W1113,W1114,W1115,W1116 +# W0707 raise-missing-from +# W1404 implicit-str-concat +# W1406 redundant-u-string-prefix + +disable=E0401,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1140,E1141,E1142,I1101,W0212,W1113,W1114,W1115,W1116,C0301,C0303,C0304,C0321,W0301,W0311,W0611,C0111,C0209,C0302,R0801,R0904,R0913,R0915,R1725,R1732,W0237,W0311,W0511,W0707,W1404,W1406
# Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -149,7 +207,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,gi.repository.GLib. # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules=gi.repository,gajim.gui,cairo +ignored-modules=gi.repository,cairo
# Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. @@ -230,12 +288,6 @@ max-line-length=80 # Maximum number of lines in a module max-module-lines=3000
-# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of an if to be on the same line as the test if there is no # else. single-line-if-stmt=no @@ -243,36 +295,21 @@ single-line-if-stmt=no
[BASIC]
-# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct argument names argument-rgx=(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$
-# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata
-# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
-# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - # Regular expression matching correct class names class-rgx=[A-Z_][a-zA-Z0-9]+$
-# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=
@@ -280,9 +317,6 @@ const-rgx= # ones are exempt. docstring-min-length=-1
-# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
@@ -292,21 +326,12 @@ good-names=i,j,k,ex,Run,_,iq # Include a hint for the correct naming format with invalid-name include-naming-hint=no
-# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
-# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
@@ -322,9 +347,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty
-# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-z0-9_]{1,30})|(_[a-z0-9_]*))$
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/c8a6c2a26b83f28ec809f166862c5853...