MartinThoma / flake8-simplify

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

[Adjust Rule] SIM113 #144

Open xqt opened 2 years ago

xqt commented 2 years ago

Desired change

Example

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

        i = 0
        for page in pagegenerators.YearPageGenerator(start, end, site):
            self.assertIsInstance(page, pywikibot.Page)
            self.assertEqual(date.formatYear(site.lang, start + i),
                             page.title())
            self.assertNotEqual(page.title(), '0')
            i += 1
            if start + i == 0:
                i += 1

Explanation

In the last line the counter variable i is adjusted. This is not the same as the value set by enumerate