Skip to content

SIM108 is bad for code coverage #14017

@maddrum

Description

@maddrum

SIM108 suggests using ternary operators whenever possible due to readability.

But ternary operators can not be covered.

Here is a well-known issue of one of the most used Python coverage tools - coverage.py

coveragepy/coveragepy#509

SIM108 should be completely removed since that is not the only issue mentioned here. It creates more problems than it actually solves.

And at the end of the day, it is quite a personal opinion if a ternary operator is easier to read, than if/else block

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions