Pycodestyle: E302 False-positive for variable names starting with `def`

Created on 30 Jan 2017  路  5Comments  路  Source: PyCQA/pycodestyle

Given the following code:

defaults = {}
defaults.update()

A false positive is reported: E302 expected 2 blank lines, found 0.

Changing of the variable name to something that doesn't start with def avoids the false positive. This is only triggered in 2.3.0, not 2.2.0.

Most helpful comment

I submitted #618 to fix this @willhardy @gpaul @bronsen. If y'all who are affected by this test that out to double-check my work, I can get a patch release out this afternoon/evening.

All 5 comments

We're affected by this, too.

As are we.

I submitted #618 to fix this @willhardy @gpaul @bronsen. If y'all who are affected by this test that out to double-check my work, I can get a patch release out this afternoon/evening.

Just checked. I can confirm your patch fixes this issue.

The fix for this was merged and released in 2.3.1.

Was this page helpful?
0 / 5 - 0 ratings