Skip to content

Control how return statements are placed in try/finally #396

@sobolevn

Description

@sobolevn

Rule request

Thesis

There's a wonderful example about return nodes in both try and finally.
https://github.com/satwikkansal/wtfPython#-return-return-everywhere

def some_func():
    try:
        return 'from_try'
    finally:
        return 'from_finally'

This will lead to an error.

Reasoning

I believe that return in finally should be restricted in case try, else, or except cases have at least a single return statement.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions