Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint: load more pylint plugins #254

Merged
merged 8 commits into from Dec 7, 2023
Merged

Conversation

bdrung
Copy link
Collaborator

@bdrung bdrung commented Nov 29, 2023

Load more pylint plugins that currently do not complain. This includes useful plugins like no_self_use. The typing plug-in detects using the deprecated typing.Tuple.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (d875b52) 83.40% compared to head (7087b15) 83.80%.
Report is 1 commits behind head on main.

Files Patch % Lines
apport/crashdb_impl/launchpad.py 0.00% 8 Missing ⚠️
tests/integration/test_signal_crashes.py 28.57% 5 Missing ⚠️
gtk/apport-gtk 40.00% 3 Missing ⚠️
apport/crashdb.py 71.42% 2 Missing ⚠️
apport/hookutils.py 50.00% 1 Missing ⚠️
apport/report.py 95.00% 1 Missing ⚠️
apport/sandboxutils.py 0.00% 1 Missing ⚠️
data/general-hooks/parse_segv.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
+ Coverage   83.40%   83.80%   +0.40%     
==========================================
  Files          93       93              
  Lines       18839    18825      -14     
==========================================
+ Hits        15712    15776      +64     
+ Misses       3127     3049      -78     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Load more pylint plugins that currently do not complain. This includes
useful plugins like `no_self_use`.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `dict_init_mutate` plug-in complains:

```
************* Module apport.crashdb_impl.launchpad
apport/crashdb_impl/launchpad.py:1073:8: C3401: Declare all known key/values when initializing the dictionary. (dict-init-mutate)
************* Module tests.unit.test_problem_report
tests/unit/test_problem_report.py:642:8: C3401: Declare all known key/values when initializing the dictionary. (dict-init-mutate)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `typing` plug-in complains:

```
************* Module apport.report
apport/report.py:96:53: W6001: 'typing.Iterator' is deprecated, use 'collections.abc.Iterator' instead (deprecated-typing-alias)
apport/report.py:316:35: W6001: 'typing.Iterable' is deprecated, use 'collections.abc.Iterable' instead (deprecated-typing-alias)
apport/report.py:681:27: W6001: 'typing.Iterable' is deprecated, use 'collections.abc.Iterable' instead (deprecated-typing-alias)
apport/report.py:782:27: W6001: 'typing.Iterable' is deprecated, use 'collections.abc.Iterable' instead (deprecated-typing-alias)
************* Module apport.ui
apport/ui.py:1014:32: W6001: 'typing.Sequence' is deprecated, use 'collections.abc.Sequence' instead (deprecated-typing-alias)
************* Module apport.crashdb_impl.github
apport/crashdb_impl/github.py:186:36: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)
apport/crashdb_impl/github.py:187:40: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)
************* Module problem_report
problem_report.py:129:29: W6001: 'typing.Iterable' is deprecated, use 'collections.abc.Iterable' instead (deprecated-typing-alias)
problem_report.py:464:49: W6001: 'typing.Iterable' is deprecated, use 'collections.abc.Iterable' instead (deprecated-typing-alias)
problem_report.py:481:9: W6001: 'typing.Generator' is deprecated, use 'collections.abc.Generator' instead (deprecated-typing-alias)
************* Module tests.helper
tests/helper.py:87:44: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)
tests/helper.py:97:5: W6001: 'typing.Generator' is deprecated, use 'collections.abc.Generator' instead (deprecated-typing-alias)
************* Module tests.paths
tests/paths.py:41:32: W6001: 'typing.Mapping' is deprecated, use 'collections.abc.Mapping' instead (deprecated-typing-alias)
tests/paths.py:53:44: W6001: 'typing.Mapping' is deprecated, use 'collections.abc.Mapping' instead (deprecated-typing-alias)
tests/paths.py:73:49: W6001: 'typing.Mapping' is deprecated, use 'collections.abc.Mapping' instead (deprecated-typing-alias)
************* Module tests.integration.test_ui
tests/integration/test_ui.py:285:9: W6001: 'typing.Generator' is deprecated, use 'collections.abc.Generator' instead (deprecated-typing-alias)
************* Module tests.integration.test_unkillable_shutdown
tests/integration/test_unkillable_shutdown.py:65:9: W6001: 'typing.Generator' is deprecated, use 'collections.abc.Generator' instead (deprecated-typing-alias)
************* Module tests.integration.test_signal_crashes
tests/integration/test_signal_crashes.py:952:37: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `typing` plug-in complains about this kind of code:

```
R6003: Consider using alternative Union syntax instead of 'Optional' (consider-alternative-union-syntax)
R6003: Consider using alternative Union syntax instead of 'Union' (consider-alternative-union-syntax)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `code_style` plug-in complains:

```
************* Module apport.fileutils
apport/fileutils.py:84:18: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module apport.ui
apport/ui.py:119:19: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module apport.packaging_impl.apt_dpkg
apport/packaging_impl/apt_dpkg.py:1490:22: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module general-hooks.parse_segv
data/general-hooks/parse_segv.py:28:19: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
data/general-hooks/parse_segv.py:144:23: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module tests.integration.test_ui
tests/integration/test_ui.py:203:17: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module tests.integration.test_unkillable_shutdown
tests/integration/test_unkillable_shutdown.py:45:51: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
************* Module tests.unit.test_fileutils
tests/unit/test_fileutils.py:189:20: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
tests/unit/test_fileutils.py:273:20: R6102: Consider using an in-place tuple instead of list (consider-using-tuple)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `comparison_placement` plug-in complains:

```
************* Module tests.system.test_packaging_apt_dpkg
tests/system/test_packaging_apt_dpkg.py:275:25: C2201: Comparison should be str(pkglist) == 3 (misplaced-comparison-constant)
tests/system/test_packaging_apt_dpkg.py:510:11: C2201: Comparison should be os.readlink(curl_library) == 'libcurl-gnutls.so' (misplaced-comparison-constant)
tests/system/test_packaging_apt_dpkg.py:521:11: C2201: Comparison should be os.readlink(curl_library) == 'libcurl-nss.so' (misplaced-comparison-constant)
tests/system/test_packaging_apt_dpkg.py:532:11: C2201: Comparison should be os.readlink(curl_library) == 'libcurl-gnutls.so' (misplaced-comparison-constant)
tests/system/test_packaging_apt_dpkg.py:853:11: C2201: Comparison should be apt_keys == '' (misplaced-comparison-constant)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `set_membership` plug-in complains:

```
************* Module apport.report
apport/report.py:1057:52: R6201: Consider using set for membership test (use-set-for-membership)
apport/report.py:1577:42: R6201: Consider using set for membership test (use-set-for-membership)
apport/report.py:1810:24: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport.sandboxutils
apport/sandboxutils.py:91:28: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport.hookutils
apport/hookutils.py:207:20: R6201: Consider using set for membership test (use-set-for-membership)
apport/hookutils.py:736:64: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport.crashdb_impl.launchpad
apport/crashdb_impl/launchpad.py:542:30: R6201: Consider using set for membership test (use-set-for-membership)
apport/crashdb_impl/launchpad.py:702:52: R6201: Consider using set for membership test (use-set-for-membership)
apport/crashdb_impl/launchpad.py:772:30: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport.packaging_impl.apt_dpkg
apport/packaging_impl/apt_dpkg.py:1564:43: R6201: Consider using set for membership test (use-set-for-membership)
apport/packaging_impl/apt_dpkg.py:1583:33: R6201: Consider using set for membership test (use-set-for-membership)
apport/packaging_impl/apt_dpkg.py:1594:52: R6201: Consider using set for membership test (use-set-for-membership)
************* Module general-hooks.parse_segv
data/general-hooks/parse_segv.py:143:19: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:295:24: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:303:40: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:319:61: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:332:24: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:377:37: R6201: Consider using set for membership test (use-set-for-membership)
data/general-hooks/parse_segv.py:392:44: R6201: Consider using set for membership test (use-set-for-membership)
************* Module problem_report
problem_report.py:749:64: R6201: Consider using set for membership test (use-set-for-membership)
************* Module tests.system.test_packaging_apt_dpkg
tests/system/test_packaging_apt_dpkg.py:936:15: R6201: Consider using set for membership test (use-set-for-membership)
************* Module tests.integration.test_report
tests/integration/test_report.py:857:33: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport-retrace
bin/apport-retrace:504:43: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport-gtk
gtk/apport-gtk:289:28: R6201: Consider using set for membership test (use-set-for-membership)
************* Module apport-kde
kde/apport-kde:206:28: R6201: Consider using set for membership test (use-set-for-membership)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
pylint's `check_elif` plug-in complains:

```
************* Module apport.fileutils
apport/fileutils.py:605:8: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module apport.crashdb
apport/crashdb.py:224:20: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module apport.crashdb_impl.launchpad
apport/crashdb_impl/launchpad.py:895:12: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
apport/crashdb_impl/launchpad.py:955:12: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module apport.packaging_impl.apt_dpkg
apport/packaging_impl/apt_dpkg.py:1291:16: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
apport/packaging_impl/apt_dpkg.py:1431:16: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module problem_report
problem_report.py:323:12: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
problem_report.py:332:16: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
problem_report.py:408:16: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module tests.integration.test_signal_crashes
tests/integration/test_signal_crashes.py:1050:12: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module apport-retrace
bin/apport-retrace:532:20: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
bin/apport-retrace:607:8: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
bin/apport-retrace:681:12: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
************* Module apport-gtk
gtk/apport-gtk:573:16: R5501: Consider using "elif" instead of "else" then "if" to remove one indentation level (else-if-used)
```

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Copy link
Contributor

@schopin-pro schopin-pro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but the weird assertion merits looking into (in a separate PR)

tests/system/test_packaging_apt_dpkg.py Show resolved Hide resolved
@schopin-pro schopin-pro merged commit 960c934 into canonical:main Dec 7, 2023
25 checks passed
@bdrung bdrung deleted the pylint branch December 7, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants