Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: PyGhidra type hint fixes

Ryan Kurtz5ab8d3359228
diff --git a/Ghidra/Features/PyGhidra/src/main/py/README.md b/Ghidra/Features/PyGhidra/src/main/py/README.md
index b6700043a5..090e8a9fe1 100644
--- a/Ghidra/Features/PyGhidra/src/main/py/README.md
+++ b/Ghidra/Features/PyGhidra/src/main/py/README.md
@@ -69,7 +69,7 @@ def open_project(
path: Union[str, Path],
name: str,
create: bool = False
-) -> "Project": # type: ignore
+) -> "Project":
"""
Opens the Ghidra project at the given location, optionally creating it if it doesn't exist.
@@ -126,7 +126,7 @@ def consume_program(
def program_context(
project: "Project",
path: Union[str, Path],
- ) -> "Program":
+ ) -> Generator["Program", None, None]:
"""
Gets the Ghidra program from the given project with the given project path. The returned
program's resource cleanup is performed by a context manager.
@@ -180,7 +180,7 @@ def ghidra_script(
def transaction(
program: "Program",
description: str = "Unnamed Transaction"
- ):
+ ) -> Generator[int, None, None]:
"""
Creates a context for running a Ghidra transaction.
@@ -339,7 +339,7 @@ def open_program(
loader: Union[str, JClass] = None,
program_name: str = None,
nested_project_location = True
-) -> ContextManager["FlatProgramAPI"]: # type: ignore
+) -> Generator["FlatProgramAPI", None, None]:
"""
Opens given binary path (or optional program name) in Ghidra and returns FlatProgramAPI object.
diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
index 7e396fc698..024636e8e7 100644
--- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
+++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py
@@ -61,7 +61,7 @@ def open_project(
path: Union[str, Path],
name: str,
create: bool = False
-) -> "Project": # type: ignore
+) -> "Project":
"""
Opens the Ghidra project at the given location, optionally creating it if it doesn't exist.