#7614 [py37] Support pylint 2.0
Closed: fixed a year ago Opened a year ago by cheimes.

Pylint 1.9 does not support Python 3.7. In order to support 3.7, pylint 2.0 is required. Pylint 2.0 is currently under development. A test run with git checkout of pylint and astroid show a large amount of new violations.


My branch https://github.com/tiran/freeipa/tree/pylint2 contains experimental support for pylint 2.0, tox -r -e pylint37. pylint2.log contains a list of bugs that can be addressed easily.

I just had to verify a patch on 4.5, that assumes pylint from Fedora 26. The output of pylint was completely useless and littered with unrelated violation.

Let's also backport all fixes to 4.6, so we can lint 4.6 branch on future versions of Fedora, too.

Metadata Update from @cheimes:
- Issue priority set to: important
- Issue set to the milestone: FreeIPA 4.6

a year ago

Metadata Update from @abiagion:
- Issue assigned to abiagion

a year ago

master:

  • b4ad0d1 Fix pylint 2.0 return-related violations

New run with latest pylint and fixes from b4ad0d1, pylint2_3.log

Summary of the remaining violations and their number of occurrences:

$ grep -o '[A-Z0-9]*([a-z-]*)' pylint2_3.log | sort | uniq -c | sort -rn
     10 R1714(consider-using-in)
      6 E0705(try-except-raise)
      4 E1111(assignment-from-no-return)
      4 C0330(bad-continuation)
      2 W1655(dict-keys-not-iterating)
      2 W1306(missing-format-attribute)
      2 W1113(keyword-arg-before-vararg)
      2 R1716(chained-comparison)
      2 R1715(consider-using-get)
      1 W1662(comprehension-escape)
      1 W1509(subprocess-popen-preexec-fn)
      1 W0715(raising-format-tuple)
      1 R1718(consider-using-set-comprehension)
      1 C0414(useless-import-alias)
      1 C0204(bad-mcs-classmethod-argument)
      1 C0113(unneeded-not)

master:

  • f48f00c pylint 2.0: node.path is a list

ipa-4-6:

  • e565809 Fix pylint 2.0 return-related violations

ipa-4-6:

  • 1895714 pylint 2.0: node.path is a list

master:

  • ba954ef Fix pylint 2.0 conditional-related violations

ipa-4-6:

  • fee6fa5 Fix pylint 2.0 conditional-related violations

There are 6 occurrences of violation E0705 try-except-raise.

The except handler raises immediately Used when an except handler uses raise as its first or only operator. This is useless because it raises back the exception immediately. Remove the raise operator or the entire try-except-raise block!

We can ignore it or we can add a log, as in:

try:
    func()
except Exception:
    logger.debug('Logging known Exception')
    raise

@cheimes What do you think?

My suggestions:

  • ipaserver/p11helper.py:477 remove the extra try/except block
  • ipaclient/plugins/vault.py:673 remove except errors.NotFound: raise but add a comment that the code propagates NotFound.
  • ipalib/backend.py:142 add an explicit ignore of the error here: except PublicError: raise # pylint: disable=try-except-raise
  • ipalib/rpc.py:1074 also add an explicit ignore: except errors.KerberosError: raise # pylint: disable=try-except-raise
  • ipapython/install/core.py:313 remove except KnobValueError: raise
  • ipapython/ipaldap.py:211 remove except IndexError: raise but keep the comment

master:

  • 4fc7f72 Teach pylint how our api works
  • aacf185 Add pylint ignore to magic config.Env attributes

master:

  • d135719 Fix Pylint 2.0 violations

ipa-4-6:

  • 3269162 Teach pylint how our api works
  • 51ce233 Add pylint ignore to magic config.Env attributes

ipa-4-6:

  • a49e933 Fix Pylint 2.0 violations

master:

  • 3ccd512 Disable Pylint 2.0 violations

ipa-4-6:

  • 46344dd Disable Pylint 2.0 violations

Pylint 2 was released and it is now supported.

In the future pylintrc must be revisited in order to remove settings added to support versions prior 2.0.0.

Metadata Update from @abiagion:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

a year ago

Login to comment on this ticket.

Metadata
Attachments 1
Attached a year ago View Comment