Skip to content

SIM103: Unnecessary if-else to return boolean #3

@MartinThoma

Description

@MartinThoma

Rule

Do not use an if-else block when you can directly return the condition.

Example

# Bad
if condition:
    return True
else
    return False

# Good
return bool(condition)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions