Skip to content

Commit

Permalink
E402: Add "if" statement to allowed keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Jan 30, 2019
1 parent 1f8d5ca commit eba7f0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ def is_string_literal(line):
line = line[1:]
return line and (line[0] == '"' or line[0] == "'")

allowed_keywords = ('try', 'except', 'else', 'finally', 'with')
allowed_keywords = (
'try', 'except', 'else', 'finally', 'with', 'if')

if indent_level: # Allow imports in conditional statement/function
return
Expand Down
5 changes: 5 additions & 0 deletions testsuite/E40.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
warnings.filterwarnings("ignore", DeprecationWarning)
import foo

import bar
#: Okay
if False:
import foo

import bar
#: E402
VERSION = '1.2.3'
Expand Down

0 comments on commit eba7f0f

Please sign in to comment.