Skip to content

Commit 7854cb4

Browse files
committed
[flake8] Just fix flake8 errors for PR #114
1 parent 052c850 commit 7854cb4

File tree

8 files changed

+175
-109
lines changed

8 files changed

+175
-109
lines changed

pyt/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131

3232

33-
def main(command_line_args=sys.argv[1:]):
33+
def main(command_line_args=sys.argv[1:]): # noqa: C901
3434
args = parse_args(command_line_args)
3535

3636
ui_mode = UImode.NORMAL

pyt/cfg/stmt_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def append_node(self, node):
717717
self.nodes.append(node)
718718
return node
719719

720-
def add_module(
720+
def add_module( # noqa: C901
721721
self,
722722
module,
723723
module_or_package_name,

pyt/core/ast_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def convert_to_3(path): # pragma: no cover
1515
try:
1616
print('##### Trying to convert file to Python 3. #####')
1717
subprocess.call(['2to3', '-w', path])
18-
except:
18+
except subprocess.SubprocessError:
1919
print('Check if 2to3 is installed. '
2020
'https://docs.python.org/2/library/2to3.html')
2121
exit(1)

pyt/core/project_handler.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,26 @@ def get_modules(path):
4040
for root, directories, filenames in os.walk(path):
4141
for filename in filenames:
4242
if is_python_file(filename):
43-
directory = os.path.dirname(os.path.realpath(os.path.join(root, filename))).split(module_root)[-1].replace(os.sep, '.')
43+
directory = os.path.dirname(
44+
os.path.realpath(
45+
os.path.join(
46+
root,
47+
filename
48+
)
49+
)
50+
).split(module_root)[-1].replace(
51+
os.sep, # e.g. '/'
52+
'.'
53+
)
4454
directory = directory.replace('.', '', 1)
4555
if directory:
46-
modules.append(('.'.join((module_root, directory, filename.replace('.py', ''))), os.path.join(root, filename)))
56+
modules.append(
57+
('.'.join((module_root, directory, filename.replace('.py', ''))), os.path.join(root, filename))
58+
)
4759
else:
48-
modules.append(('.'.join((module_root, filename.replace('.py', ''))), os.path.join(root, filename)))
60+
modules.append(
61+
('.'.join((module_root, filename.replace('.py', ''))), os.path.join(root, filename))
62+
)
4963

5064
return modules
5165

tests/analysis/reaching_definitions_taint_test.py

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ def test_linear_program(self):
1313
"Label: ~call_1 = ret_input(): Label: ~call_1 = ret_input()",
1414
"Label: x = ~call_1: Label: x = ~call_1, Label: ~call_1 = ret_input()",
1515
"Label: y = x - 1: Label: y = x - 1, Label: x = ~call_1, Label: ~call_1 = ret_input()",
16-
"Label: ~call_2 = ret_print(x): Label: ~call_2 = ret_print(x), Label: y = x - 1, Label: x = ~call_1, Label: ~call_1 = ret_input()",
17-
"Label: Exit module: Label: ~call_2 = ret_print(x), Label: y = x - 1, Label: x = ~call_1, Label: ~call_1 = ret_input()"
16+
"""Label: ~call_2 = ret_print(x): Label: ~call_2 = ret_print(x), Label: y = x - 1,
17+
Label: x = ~call_1, Label: ~call_1 = ret_input()""",
18+
"""Label: Exit module: Label: ~call_2 = ret_print(x), Label: y = x - 1, Label: x = ~call_1,
19+
Label: ~call_1 = ret_input()"""
1820
]
1921
i = 0
2022
for k, v in constraint_table.items():
@@ -31,8 +33,10 @@ def test_if_program(self):
3133
"Label: x = ~call_1: Label: x = ~call_1, Label: ~call_1 = ret_input()",
3234
"Label: if x > 0:: Label: x = ~call_1, Label: ~call_1 = ret_input()",
3335
"Label: y = x + 1: Label: y = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_input()",
34-
"Label: ~call_2 = ret_print(x): Label: ~call_2 = ret_print(x), Label: y = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_input()",
35-
"Label: Exit module: Label: ~call_2 = ret_print(x), Label: y = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_input()"
36+
"""Label: ~call_2 = ret_print(x): Label: ~call_2 = ret_print(x), Label: y = x + 1,
37+
Label: x = ~call_1, Label: ~call_1 = ret_input()""",
38+
"""Label: Exit module: Label: ~call_2 = ret_print(x), Label: y = x + 1, Label: x = ~call_1,
39+
Label: ~call_1 = ret_input()"""
3640
]
3741
i = 0
3842
for k, v in constraint_table.items():
@@ -49,16 +53,28 @@ def test_example(self):
4953
"Label: x = ~call_1: Label: x = ~call_1, Label: ~call_1 = ret_input()",
5054
"Label: ~call_2 = ret_int(x): Label: ~call_2 = ret_int(x), Label: x = ~call_1, Label: ~call_1 = ret_input()",
5155
"Label: x = ~call_2: Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
52-
"Label: while x > 1:: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
53-
"Label: y = x / 2: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
54-
"Label: if y > 3:: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
55-
"Label: x = x - y: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
56-
"Label: z = x - 4: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
57-
"Label: if z > 0:: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
58-
"Label: x = x / 2: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
59-
"Label: z = z - 1: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
60-
"Label: ~call_3 = ret_print(x): Label: ~call_3 = ret_print(x), Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()",
61-
"Label: Exit module: Label: ~call_3 = ret_print(x), Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()"
56+
"""Label: while x > 1:: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2,
57+
Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
58+
"""Label: y = x / 2: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2,
59+
Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
60+
"""Label: if y > 3:: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2,
61+
Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
62+
"""Label: x = x - y: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2,
63+
Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
64+
"""Label: z = x - 4: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2,
65+
Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
66+
"""Label: if z > 0:: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2,
67+
Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
68+
"""Label: x = x / 2: Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2, Label: x = ~call_2,
69+
Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
70+
"""Label: z = z - 1: Label: z = z - 1, Label: x = x / 2, Label: z = x - 4, Label: x = x - y, Label: y = x / 2,
71+
Label: x = ~call_2, Label: ~call_2 = ret_int(x), Label: ~call_1 = ret_input()""",
72+
"""Label: ~call_3 = ret_print(x): Label: ~call_3 = ret_print(x), Label: z = z - 1, Label: x = x / 2, Label: z = x - 4,
73+
Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x),
74+
Label: ~call_1 = ret_input()""",
75+
"""Label: Exit module: Label: ~call_3 = ret_print(x), Label: z = z - 1, Label: x = x / 2, Label: z = x - 4,
76+
Label: x = x - y, Label: y = x / 2, Label: x = ~call_2, Label: ~call_2 = ret_int(x),
77+
Label: ~call_1 = ret_input()"""
6278
]
6379
i = 0
6480
for k, v in constraint_table.items():
@@ -88,13 +104,19 @@ def test_while(self):
88104
"Label: ~call_2 = ret_input(): Label: ~call_2 = ret_input()",
89105
"Label: ~call_1 = ret_int(~call_2): Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
90106
"Label: x = ~call_1: Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
91-
"Label: while x < 10:: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input(",
92-
"Label: x = x + 1: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
93-
"Label: if x == 5:: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
94-
"Label: BreakNode: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
107+
"""Label: while x < 10:: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2),
108+
Label: ~call_2 = ret_input(""",
109+
"""Label: x = x + 1: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2),
110+
Label: ~call_2 = ret_input()""",
111+
"""Label: if x == 5:: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2),
112+
Label: ~call_2 = ret_input()""",
113+
"""Label: BreakNode: Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2),
114+
Label: ~call_2 = ret_input()""",
95115
"Label: x = 6: Label: x = 6, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
96-
"Label: ~call_3 = ret_print(x): Label: ~call_3 = ret_print(x), Label: x = 6, Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()",
97-
"Label: Exit module: Label: ~call_3 = ret_print(x), Label: x = 6, Label: x = x + 1, Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()"
116+
"""Label: ~call_3 = ret_print(x): Label: ~call_3 = ret_print(x), Label: x = 6, Label: x = x + 1,
117+
Label: x = ~call_1, Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()""",
118+
"""Label: Exit module: Label: ~call_3 = ret_print(x), Label: x = 6, Label: x = x + 1, Label: x = ~call_1,
119+
Label: ~call_1 = ret_int(~call_2), Label: ~call_2 = ret_input()"""
98120
]
99121
i = 0
100122
for k, v in constraint_table.items():

0 commit comments

Comments
 (0)