By DeepSource

Found redundant self-assignment branch RB-C1014

Anti-pattern Autofix

Self-assignment branches should be avoided as they are inefficient, unmaintanable and lack reability. Instead it is recommended to use single line conditionals if you need to make assignments.

It is considered inefficient as it generates extra assignment statements, this can have a large impact when such statements are called from within a loop. It is generally less maintanable when you have a bunch of such statements and you make a change to foo's assignment logic, you will need to make sure that its tested everywhere.

Bad practice

foo = condition ? bar : foo
foo = condition ? foo : bar


foo = bar if condition
foo = bar unless condition