Skip to content

Commit

Permalink
Fix Flake8 Errors (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kwsm committed Oct 15, 2021
1 parent d554122 commit 9678405
Show file tree
Hide file tree
Showing 18 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion examples/dump_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# your site-packages/ with setup.py
sys.path.extend(['.', '..'])

from pycparser import c_parser, c_ast, parse_file
from pycparser import parse_file

if __name__ == "__main__":
argparser = argparse.ArgumentParser('Dump AST')
Expand Down
2 changes: 1 addition & 1 deletion examples/explore_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
sys.path.extend(['.', '..'])

from pycparser import c_parser, c_ast
from pycparser import c_parser

# This is some C source to parse. Note that pycparser must begin
# at the top level of the C file, i.e. with either declarations
Expand Down
2 changes: 1 addition & 1 deletion examples/func_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# your site-packages/ with setup.py
sys.path.extend(['.', '..'])

from pycparser import c_parser, c_ast, parse_file
from pycparser import c_ast, parse_file


# A visitor with some state information (the funcname it's looking for)
Expand Down
2 changes: 1 addition & 1 deletion examples/func_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# your site-packages/ with setup.py
sys.path.extend(['.', '..'])

from pycparser import c_parser, c_ast, parse_file
from pycparser import c_ast, parse_file


# A simple visitor for FuncDef nodes that prints the names and
Expand Down
1 change: 0 additions & 1 deletion examples/func_defs_add_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
import sys

from pycparser import c_parser, c_ast, c_generator

Expand Down
1 change: 0 additions & 1 deletion examples/rewrite_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
import sys

from pycparser import c_parser

Expand Down
1 change: 0 additions & 1 deletion pycparser/_ast_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
import pprint
from string import Template


Expand Down
1 change: 0 additions & 1 deletion pycparser/c_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# License: BSD
#------------------------------------------------------------------------------
import re
import sys

from .ply import lex
from .ply.lex import TOKEN
Expand Down
6 changes: 2 additions & 4 deletions pycparser/c_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
import re

from .ply import yacc

from . import c_ast
from .c_lexer import CLexer
from .plyparser import PLYParser, Coord, ParseError, parameterized, template
from .plyparser import PLYParser, ParseError, parameterized, template
from .ast_transforms import fix_switch_cases, fix_atomic_specifiers


Expand Down Expand Up @@ -1221,7 +1219,7 @@ def p_direct_xxx_declarator_5(self, p):
arr = c_ast.ArrayDecl(
type=None,
dim=c_ast.ID(p[4], self._token_coord(p, 4)),
dim_quals=p[3] if p[3] != None else [],
dim_quals=p[3] if p[3] is not None else [],
coord=p[1].coord)

p[0] = self._type_modify_decl(decl=p[1], modifier=arr)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_c_ast.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pprint
import re
import sys
import unittest
import weakref
Expand Down
1 change: 0 additions & 1 deletion tests/test_c_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import sys
import unittest

Expand Down
6 changes: 2 additions & 4 deletions tests/test_c_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python

import pprint
import re
import os, sys
import io
import unittest
Expand All @@ -10,7 +8,7 @@

from pycparser import c_parser
from pycparser.c_ast import *
from pycparser.c_parser import CParser, Coord, ParseError
from pycparser.c_parser import ParseError

_c_parser = c_parser.CParser(
lex_optimize=False,
Expand Down Expand Up @@ -729,7 +727,7 @@ def test_compound_literals(self):
def test_parenthesized_compounds(self):
e = self.parse(r'''
void foo() {
int a;
int a;
({});
({ 1; });
({ 1; 2; });
Expand Down
1 change: 0 additions & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import platform
import sys
import unittest

Expand Down
3 changes: 2 additions & 1 deletion utils/internal/fake_includes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import print_function
import os.path

for cur_path, dirs, files in os.walk('.'):
if cur_path == '.':
for f in files:
if f.endswith('.h'):
print f
print(f)
fo = open(f, 'w')
fo.write('#include "_fake_defines.h"\n')
fo.write('#include "_fake_typedefs.h"\n')
Expand Down
5 changes: 3 additions & 2 deletions utils/internal/make_fake_typedefs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import print_function
import sys
sys.path.insert(0, '../..')

from pycparser import c_parser, c_ast, parse_file
from pycparser import c_ast, parse_file


class MyVisitor(c_ast.NodeVisitor):
def visit_Typedef(self, node):
print 'typedef int %s;' % node.name
print('typedef int %s;' % node.name)



Expand Down
4 changes: 1 addition & 3 deletions utils/internal/memprofiling.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
from pycparser import parse_file
from pycparser.c_ast import *
from pycparser.c_parser import CParser, Coord, ParseError
from pycparser.c_lexer import CLexer
from pycparser.c_parser import CParser


def expand_decl(decl):
Expand Down
2 changes: 1 addition & 1 deletion utils/internal/zz-ctoc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import print_function
from pycparser import parse_file, c_parser, c_generator
from pycparser import c_parser, c_generator

if __name__ == '__main__':
src = r'''
Expand Down
3 changes: 1 addition & 2 deletions utils/internal/zz_parse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import print_function

import sys
from pycparser import c_parser, c_generator, c_ast, parse_file
from pycparser import c_parser, c_generator


if __name__ == "__main__":
Expand Down

0 comments on commit 9678405

Please sign in to comment.