Skip to content

Commit

Permalink
Merge pull request #71 from google/ci
Browse files Browse the repository at this point in the history
Fix ruff findings.
  • Loading branch information
AidenRHall authored Aug 30, 2023
2 parents efc205b + 470a839 commit 386a7fc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
2 changes: 0 additions & 2 deletions src/coverage_g3test.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,10 @@ def testConstCompare(self, trace_branch_mock, trace_cmp_mock,

self.assertTrue(cmp_const_less(2))
self.assertTraceCmpWas(trace_cmp_mock.call_args[0], 1, 2, "<", True)
first_cmp_idx = trace_cmp_mock.call_args[0][3]
trace_cmp_mock.reset_mock()

self.assertFalse(cmp_const_less_inverted(3))
self.assertTraceCmpWas(trace_cmp_mock.call_args[0], 1, 3, ">", True)
first_cmp_idx = trace_cmp_mock.call_args[0][3]
trace_cmp_mock.reset_mock()

def testInstrumentationAppliedOnce(self, trace_branch_mock, trace_cmp_mock,
Expand Down
2 changes: 0 additions & 2 deletions src/coverage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,10 @@ def testConstCompare(self, trace_branch_mock, trace_cmp_mock,

self.assertTrue(coverage_test_helper.cmp_const_less(2))
self.assertTraceCmpWas(trace_cmp_mock.call_args[0], 1, 2, "<", True)
first_cmp_idx = trace_cmp_mock.call_args[0][3]
trace_cmp_mock.reset_mock()

self.assertFalse(coverage_test_helper.cmp_const_less_inverted(3))
self.assertTraceCmpWas(trace_cmp_mock.call_args[0], 1, 3, ">", True)
first_cmp_idx = trace_cmp_mock.call_args[0][3]
trace_cmp_mock.reset_mock()

def testInstrumentationAppliedOnce(self, trace_branch_mock, trace_cmp_mock,
Expand Down
12 changes: 6 additions & 6 deletions src/fuzzed_data_provider_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def to_bytes(n, length):

else:
# functionality from python3's chr() function is called unichr() in python2
codepoint = unichr
codepoint = unichr # noqa: F821

# functionality from python3's int.to_bytes()
def to_bytes(n, length):
Expand Down Expand Up @@ -250,7 +250,7 @@ def testIntList1(self):
arr += to_bytes(random.randint(0, 255), 1)
fdp = atheris.FuzzedDataProvider(arr)

l = fdp.ConsumeIntList(4321, 1)
l = fdp.ConsumeIntList(4321, 1) # noqa: E741
self.assertEqual(len(l), 4321)
for i in range(0, 1000):
if arr[i] < 0:
Expand All @@ -271,7 +271,7 @@ def testIntList9(self):
arr += to_bytes(random.randint(0, 2**72 - 1), 9)
fdp = atheris.FuzzedDataProvider(arr)

l = fdp.ConsumeIntList(4321, 9)
l = fdp.ConsumeIntList(4321, 9) # noqa: E741
self.assertEqual(len(l), 4321)

for i in range(0, 1000):
Expand Down Expand Up @@ -355,7 +355,7 @@ def testFloatList(self):
self.assertLess(val, 1.79769313e+308)

def testPickValueInList1(self):
l = [3, 3]
l = [3, 3] # noqa: E741

arr = to_bytes(random.getrandbits(1024), int(1024 / 8))
arr = to_bytes(1234, 8) + arr
Expand All @@ -368,7 +368,7 @@ def testPickValueInList1(self):
self.assertEqual(fdp.PickValueInList(l), 3)

def testPickValueInList7(self):
l = [4, 17, 52, 12, 8, 71, 2]
l = [4, 17, 52, 12, 8, 71, 2] # noqa: E741
s = set()

arr = to_bytes(random.getrandbits(1024 * 1024), int(1024 * 1024 / 8))
Expand All @@ -381,7 +381,7 @@ def testPickValueInList7(self):
self.assertEqual(fdp.PickValueInList(l), 4)

def testPickValueInListShort(self):
l = []
l = [] # noqa: E741
for i in range(1, 10001):
l.append(i * 13)

Expand Down
10 changes: 0 additions & 10 deletions src/instrument_bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@
from .version_dependent import rel_reference_scale
from .version_dependent import REVERSE_CMP_OP
from .version_dependent import rot_n
from .version_dependent import call
from .version_dependent import cache_count
from .version_dependent import caches
from .version_dependent import get_instructions
from .version_dependent import generate_exceptiontable
from .version_dependent import parse_exceptiontable
from .version_dependent import ExceptionTableEntry
from .version_dependent import args_terminator
from .version_dependent import CALLABLE_STACK_ENTRIES
from .version_dependent import UNCONDITIONAL_JUMPS

_TARGET_MODULE = "atheris"
Expand Down Expand Up @@ -786,7 +777,6 @@ def trace_control_flow(self) -> None:
# Insert at the first point after a RESUME instruction
first_real_instr = None
first_real_instr_slot = None
previous_instructions = []
for i in range(len(self._cfg[0].instructions)):
bb_instr = self._cfg[0].instructions[i]
if bb_instr.mnemonic not in ("RESUME", "GEN_START"):
Expand Down
4 changes: 2 additions & 2 deletions src/version_dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ def parse_exceptiontable(code):
if (3, 11) <= PYTHON_VERSION <= (3, 11):
from .native import _generate_exceptiontable

def generate_exceptiontable(original_code, exception_table_entries):
def generate_exceptiontable(original_code, exception_table_entries): # noqa: F811
return _generate_exceptiontable(original_code, exception_table_entries)

def parse_exceptiontable(co_exceptiontable):
def parse_exceptiontable(co_exceptiontable): # noqa: F811
if isinstance(co_exceptiontable, types.CodeType):
return parse_exceptiontable(co_exceptiontable.co_exceptiontable)

Expand Down

0 comments on commit 386a7fc

Please sign in to comment.