From 583f6c8d7aba5fb2ff0f5e1d60c34d1a5327e51a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 31 May 2024 20:21:12 +1000 Subject: [PATCH] Run pytype in GitHub Actions --- .github/workflows/builds.yaml | 4 +++- src/coverage_test.py | 2 +- src/custom_crossover_fuzz_test.py | 2 +- src/custom_mutator_and_crossover_fuzz_test.py | 2 +- src/custom_mutator_fuzz_test.py | 2 +- src/fuzz_test.py | 2 +- src/fuzzed_data_provider_test.py | 4 ++-- src/version_dependent.py | 6 +++--- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/builds.yaml b/.github/workflows/builds.yaml index b7f46026..6fc849af 100644 --- a/.github/workflows/builds.yaml +++ b/.github/workflows/builds.yaml @@ -19,9 +19,11 @@ jobs: python-version: '3.11' cache: 'pip' - name: Install dependencies - run: pip3 install ruff + run: pip3 install asn1crypto atheris pytype ruff - name: Run ruff checks run: ruff check src + - name: Run pytype checks + run: pytype src # mypy: # runs-on: ubuntu-latest # steps: diff --git a/src/coverage_test.py b/src/coverage_test.py index 5dc983a6..7f55e570 100644 --- a/src/coverage_test.py +++ b/src/coverage_test.py @@ -21,7 +21,7 @@ import atheris with atheris.instrument_imports(): - import coverage_test_helper + import coverage_test_helper # pytype: disable=import-error # Enable RegEx instrumentation. atheris.enabled_hooks.add("RegEx") diff --git a/src/custom_crossover_fuzz_test.py b/src/custom_crossover_fuzz_test.py index 3d090729..780e6611 100644 --- a/src/custom_crossover_fuzz_test.py +++ b/src/custom_crossover_fuzz_test.py @@ -19,7 +19,7 @@ import atheris -import fuzz_test_lib +import fuzz_test_lib # pytype: disable=import-error def concatenate_crossover(data1, data2, max_size, seed): diff --git a/src/custom_mutator_and_crossover_fuzz_test.py b/src/custom_mutator_and_crossover_fuzz_test.py index 02afa21c..b9f5cacc 100644 --- a/src/custom_mutator_and_crossover_fuzz_test.py +++ b/src/custom_mutator_and_crossover_fuzz_test.py @@ -19,7 +19,7 @@ import atheris -import fuzz_test_lib +import fuzz_test_lib # pytype: disable=import-error def noop_mutator(data, max_size, seed): diff --git a/src/custom_mutator_fuzz_test.py b/src/custom_mutator_fuzz_test.py index 1d9436c0..eeab9c07 100644 --- a/src/custom_mutator_fuzz_test.py +++ b/src/custom_mutator_fuzz_test.py @@ -19,7 +19,7 @@ import atheris -import fuzz_test_lib +import fuzz_test_lib # pytype: disable=import-error def compressed_mutator(data, max_size, seed): diff --git a/src/fuzz_test.py b/src/fuzz_test.py index ab7e566c..85621b6b 100644 --- a/src/fuzz_test.py +++ b/src/fuzz_test.py @@ -22,7 +22,7 @@ import atheris -import fuzz_test_lib +import fuzz_test_lib # pytype: disable=import-error def fail_immediately(data): diff --git a/src/fuzzed_data_provider_test.py b/src/fuzzed_data_provider_test.py index b01409cc..722df76b 100644 --- a/src/fuzzed_data_provider_test.py +++ b/src/fuzzed_data_provider_test.py @@ -245,10 +245,10 @@ def testInRange9(self): self.assertLessEqual(result, one) def testIntList1(self): - arr = b"" + arr = bytearray() for _ in range(0, 1000): arr += to_bytes(random.randint(0, 255), 1) - fdp = atheris.FuzzedDataProvider(arr) + fdp = atheris.FuzzedDataProvider(bytes(arr)) l = fdp.ConsumeIntList(4321, 1) # noqa: E741 self.assertEqual(len(l), 4321) diff --git a/src/version_dependent.py b/src/version_dependent.py index 627c6e66..ac9ae14f 100644 --- a/src/version_dependent.py +++ b/src/version_dependent.py @@ -329,7 +329,7 @@ def get_lnotab(code, listing): elif (3, 11) <= PYTHON_VERSION <= (3, 11): - from .native import _generate_codetable + from .native import _generate_codetable # pytype: disable=import-error def get_lnotab(code, listing): ret = _generate_codetable(code, listing) return ret @@ -392,7 +392,7 @@ def parse_exceptiontable(code): if (3, 11) <= PYTHON_VERSION <= (3, 11): - from .native import _generate_exceptiontable + from .native import _generate_exceptiontable # pytype: disable=import-error def generate_exceptiontable(original_code, exception_table_entries): # noqa: F811 return _generate_exceptiontable(original_code, exception_table_entries) @@ -497,7 +497,7 @@ def cache_count(op): if isinstance(op, str): op = dis.opmap[op] - return opcode._inline_cache_entries[op] + return getattr(opcode, '_inline_cache_entries')[op] # Generate a list of CACHE instructions for the given instr. def caches(op):