#7614 [py37] Support pylint 2.0
Closed: fixed Opened 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

Metadata Update from @abiagion:
- Issue assigned to abiagion

master:

  • b4ad0d19a20cc66690e7f4e9c4327afeedff2ab2 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:

  • f48f00c692d10541171ff5267cf20ccee74f2ad5 pylint 2.0: node.path is a list

ipa-4-6:

  • e56580999126ebec4f6feb739a43b408354ffb03 Fix pylint 2.0 return-related violations

ipa-4-6:

  • 1895714115eac84a3c0e4aa4571fb76f3bcaf424 pylint 2.0: node.path is a list

master:

  • ba954efafdb3e430c76dfc327d2b683ac0e117eb Fix pylint 2.0 conditional-related violations

ipa-4-6:

  • fee6fa5033f8fc7ab0435676c4ecf60efef5f206 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:

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

master:

  • d13571942e41370fdbd2b6f9960c484fa61c3404 Fix Pylint 2.0 violations

ipa-4-6:

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

ipa-4-6:

  • a49e933eb6aef3531ce4f2e705d2d525cbfe4329 Fix Pylint 2.0 violations

master:

  • 3ccd512dab1ce325aad99c39e71ade36db826028 Disable Pylint 2.0 violations

ipa-4-6:

  • 46344dd23a1059526c0dd331530c5f84237e115c 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)

Metadata