Page MenuHomePhabricator

Solve Inconsistent return statements
Open, LowPublic

Description

Introduction

Due to PEP8 [1] either all return statements in a function should return an expression, or none of them should.

# Correct:

def bar(x):
    if x < 0:
        return None
    return math.sqrt(x)
# Wrong:

def foo(x):
    if x >= 0:
        return math.sqrt(x)
   # implicit returns None here which should be explicit

def bar(x):
    if x < 0:
        return  # implicit returns None here which should be explicit
    return math.sqrt(x)

What to do

Issues to be solved can be found here:
https://deepsource.io/gh/xqt/pwb/issue/PYL-R1710/occurrences

Fix it by adding consistent return statements.
Please split your patch into smaller parts (no more than 20 methods at once) because it is heave to review a bulk of changed lines.

[1] https://peps.python.org/pep-0008/#programming-recommendations

Event Timeline

Xqt triaged this task as Low priority.Apr 11 2022, 3:23 PM

Change 808289 had a related patch set uploaded (by Vivian Rook; author: Vivian Rook):

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 808289 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 808918 had a related patch set uploaded (by Vivian Rook; author: Vivian Rook):

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 808918 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 809006 had a related patch set uploaded (by Vivian Rook; author: Vivian Rook):

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 809006 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 809615 had a related patch set uploaded (by Vivian Rook; author: Vivian Rook):

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 809615 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 812894 had a related patch set uploaded (by Vivian Rook; author: Vivian Rook):

[pywikibot/core@master] [IMPR] PEP8 updates

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

Change 812894 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] PEP8 updates

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