Page MenuHomePhabricator

hacking gives false positives H233
Closed, ResolvedPublic

Description

CI tests with flake8 hacking extension gives false positives for the following case:
codeline = 'if print or self.opt.put or self.opt.tofile:'

the detection regex of hacking is:
RE_PRINT = re.compile(r"\bprint(?:$|\s+[^\(])")

RE_PRINT.findall(line) unexpectadly finds ['print o']

The right regex needs a negative lookbehind and might be:
RE_PRINT = re.compile(r"(?<!\.)\bprint(?:$|\s+[^\(])")

Unfortunately hacking has a its issue tracker at ubuntu one where an account is required. (I don't have one and don't want to create one.)

See: https://bugs.launchpad.net/hacking

Event Timeline

Xqt renamed this task from hacking gives fallse positives H233 to hacking gives false positives H233.May 28 2024, 10:36 AM
Xqt triaged this task as Medium priority.
Xqt moved this task from Backlog to Upstream issues on the Pywikibot board.
Xqt moved this task from Backlog to Upstream issues on the Pywikibot-tests board.
Xqt moved this task from Backlog to To upstream/missing upstream link on the Upstream board.

I propose to remove all H23 test because they are for Python 2 I guess.

Change #1036666 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [tests] Ignore Python 3 compatibility tests with hacking

https://gerrit.wikimedia.org/r/1036666

Change #1036666 merged by Xqt:

[pywikibot/core@master] [tests] Ignore Python 3 compatibility tests with hacking

https://gerrit.wikimedia.org/r/1036666

Xqt claimed this task.