Skip to content

Commit b125164

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
types: Add type annotations to jitlist_bisect.py
Summary: Added type annotations to all functions in jitlist_bisect.py that were missing them: `write_jitlist`, `read_jitlist`, `get_compiled_funcs`, `run_bisect`, `parse_args`, and `main`. This improves code readability and enables better static analysis. Reviewed By: yoney Differential Revision: D99294381 fbshipit-source-id: 47e09ac15ce3fa5ce018dd7e5b6a1095eed1753d
1 parent f9b8569 commit b125164

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

cinderx/TestScripts/jitlist_bisect.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
JITLIST_FILENAME = "jitlist.txt"
1414

1515

16-
def write_jitlist(jitlist):
16+
def write_jitlist(jitlist: list[str]) -> None:
1717
with open(JITLIST_FILENAME, "w") as file:
1818
for func in jitlist:
1919
print(func, file=file)
2020

2121

22-
def read_jitlist(jit_list_file):
22+
def read_jitlist(jit_list_file: str) -> list[str]:
2323
with open(jit_list_file) as file:
2424
return [line.strip() for line in file.readlines()]
2525

2626

2727
COMPILED_FUNC_RE = re.compile(r" -- (Compiling|Inlining function) ([^ ]+)($| into)")
2828

2929

30-
def get_compiled_funcs(command):
30+
def get_compiled_funcs(command: list[str]) -> list[str]:
3131
environ = dict(os.environ)
3232
environ.update({"PYTHONJITDEBUG": "1"})
3333

@@ -55,7 +55,7 @@ def get_compiled_funcs(command):
5555
return sorted(funcs)
5656

5757

58-
def run_bisect(command, jit_list_file):
58+
def run_bisect(command: list[str], jit_list_file: str | None) -> None:
5959
if len(command) == 0:
6060
sys.exit("No command specified")
6161

@@ -99,7 +99,7 @@ def run_bisect(command, jit_list_file):
9999
)
100100

101101

102-
def parse_args():
102+
def parse_args() -> argparse.Namespace:
103103
parser = argparse.ArgumentParser(
104104
description="When given a command that fails with the jit enabled (including -X jit as appropriate), bisects to find a minimal jit-list that preserves the failure"
105105
)
@@ -116,7 +116,7 @@ def parse_args():
116116
return parser.parse_args()
117117

118118

119-
def main():
119+
def main() -> None:
120120
args = parse_args()
121121
config_logger(args.verbose)
122122
run_bisect(args.command, args.initial_jit_list_file)

0 commit comments

Comments
 (0)