MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
185 stars 19 forks source link

[Adjust Rule] SIM908: odd transform for self-assign #141

Open Skylion007 opened 2 years ago

Skylion007 commented 2 years ago

Desired change

Explanation

This is an example where the mentioned rule(s) would currently be suboptimal:

        if "state_dict" in cpt:
            cpt = cpt["state_dict"]
        cpt = cpt.get("state_dict", cpt)

Is actually harder to read in this case.