Skip to content

False negative for no-else-return after except #7788

Closed
@nickdrozd

Description

@nickdrozd

Bug description

This snippet returns in the except block, and therefore the else is unnecessary:

def f() -> bool:
    try:
        print('asdf')
    except:  # pylint: disable = bare-except
        return False
    else:
        return True

It should raise no-else-return.

Configuration

No response

Command used

`pylint asdf.py`

Pylint output

No warnings raised

Expected behavior

Should raise no-else-return

Pylint version

pylint 2.16.0-dev
astroid 2.13.0-dev0
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 

Metadata

Metadata

Assignees

Labels

False Negative 🦋No message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributors

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions