Skip to content

Commit

Permalink
Added additional type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin authored Jun 6, 2024
2 parents d315034 + 57b2e86 commit 54accd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os


def path():
def path() -> str:
dir, _ = os.path.split(sys.modules["atheris"].__file__)
dir, _ = os.path.split(dir)
return dir
Expand All @@ -26,7 +26,7 @@ def path():
class ProgressRenderer:
"""Displays an updating progress meter in the terminal."""

def __init__(self, stream, total_count):
def __init__(self, stream, total_count: int):
assert stream.isatty()
self.stream = stream

Expand Down Expand Up @@ -56,10 +56,10 @@ def drop(self):
sys.stderr.write("\n")

@property
def count(self):
def count(self) -> int:
return self._count

@count.setter
def count(self, new_count):
def count(self, new_count: int):
self._count = new_count
self.render()
10 changes: 5 additions & 5 deletions src/version_dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
# Returns -1 for instructions that have backward relative references
# (e.g. JUMP_BACKWARD, an instruction that uses a positive number to
# indicate a negative jump)
def rel_reference_scale(opname):
def rel_reference_scale(opname: str) -> int:
assert opname in HAVE_REL_REFERENCE
if opname in REL_REFERENCE_IS_INVERTED:
return -1
Expand Down Expand Up @@ -345,12 +345,12 @@ def __init__(self, start_offset, end_offset, target, depth, lasti):
self.depth = depth
self.lasti = lasti

def __repr__(self):
def __repr__(self) -> str:
return (
f"(start_offset={self.start_offset} end_offset={self.end_offset} target={self.target} depth={self.depth} lasti={self.lasti})"
)

def __str__(self):
def __str__(self) -> str:
return self.__repr__()

def __eq__(self, other):
Expand All @@ -368,10 +368,10 @@ class ExceptionTable:
def __init__(self, entries: List[ExceptionTableEntry]):
self.entries = entries

def __repr__(self):
def __repr__(self) -> str:
return "\n".join([repr(x) for x in self.entries])

def __str__(self):
def __str__(self) -> str:
return "\n".join([repr(x) for x in self.entries])

def __eq__(self, other):
Expand Down

0 comments on commit 54accd9

Please sign in to comment.