From 5944b4bbcbc90dcc37ce38a1955a3dfeb248f057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 24 Apr 2024 13:14:11 +0200 Subject: [PATCH] Fix stylistic inconsistencies --- frida/_frida/__init__.pyi | 89 ++++++++++++++++++ frida/core.py | 188 +++++++++++++------------------------- setup.py | 6 +- 3 files changed, 157 insertions(+), 126 deletions(-) diff --git a/frida/_frida/__init__.pyi b/frida/_frida/__init__.pyi index f37482d..cd7c7ea 100644 --- a/frida/_frida/__init__.pyi +++ b/frida/_frida/__init__.pyi @@ -23,6 +23,7 @@ class Object: Add a signal handler. """ ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: """ Remove a signal handler. @@ -36,18 +37,21 @@ class Application(Object): Application identifier. """ ... + @property def name(self) -> str: """ Human-readable application name. """ ... + @property def parameters(self) -> Dict[str, Any]: """ Parameters. """ ... + @property def pid(self) -> int: """ @@ -61,6 +65,7 @@ class Bus(Object): Attach to the bus. """ ... + def post(self, message: str, data: Optional[Union[bytes, str]]) -> None: """ Post a JSON-encoded message to the bus. @@ -73,47 +78,56 @@ class Cancellable(Object): Set cancellable to cancelled. """ ... + def connect(self, callback: Callable[..., Any]) -> int: """ Register notification callback. """ ... + def disconnect(self, handler_id: int) -> None: """ Unregister notification callback. """ ... + @classmethod def get_current(cls) -> "Cancellable": """ Get the top cancellable from the stack. """ ... + def get_fd(self) -> int: """ Get file descriptor for integrating with an event loop. """ ... + def is_cancelled(self) -> bool: """ Query whether cancellable has been cancelled. """ ... + def pop_current(self) -> None: """ Pop cancellable off the cancellable stack. """ ... + def push_current(self) -> None: """ Push cancellable onto the cancellable stack. """ ... + def raise_if_cancelled(self) -> None: """ Raise an exception if cancelled. """ ... + def release_fd(self) -> None: """ Release a resource previously allocated by get_fd(). @@ -127,36 +141,42 @@ class Child(Object): Argument vector. """ ... + @property def envp(self) -> Dict[str, str]: """ Environment vector. """ ... + @property def identifier(self) -> str: """ Application identifier. """ ... + @property def origin(self) -> str: """ Origin. """ ... + @property def parent_pid(self) -> int: """ Parent Process ID. """ ... + @property def path(self) -> str: """ Path of executable. """ ... + @property def pid(self) -> int: """ @@ -171,24 +191,28 @@ class Crash(Object): Parameters. """ ... + @property def pid(self) -> int: """ Process ID. """ ... + @property def process_name(self) -> str: """ Process name. """ ... + @property def report(self) -> str: """ Human-readable crash report. """ ... + @property def summary(self) -> str: """ @@ -203,45 +227,53 @@ class Device(Object): Device ID. """ ... + @property def name(self) -> Optional[str]: """ Human-readable device name. """ ... + @property def icon(self) -> Optional[Any]: """ Icon. """ ... + @property def type(self) -> Optional[str]: """ Device type. One of: local, remote, usb. """ ... + @property def bus(self) -> Optional[Bus]: """ Message bus. """ ... + def attach(self, pid: int, realm: Optional[str] = None, persist_timeout: Optional[int] = None) -> "Session": """ Attach to a PID. """ ... + def disable_spawn_gating(self) -> None: """ Disable spawn gating. """ ... + def enable_spawn_gating(self) -> None: """ Enable spawn gating. """ ... + def enumerate_applications( self, identifiers: Optional[Sequence[str]] = None, scope: Optional[str] = None ) -> List[Application]: @@ -249,71 +281,85 @@ class Device(Object): Enumerate applications. """ ... + def enumerate_pending_children(self) -> List[Child]: """ Enumerate pending children. """ ... + def enumerate_pending_spawn(self) -> List["Spawn"]: """ Enumerate pending spawn. """ ... + def enumerate_processes(self, pids: Optional[Sequence[int]] = None, scope: Optional[str] = None) -> List[Process]: """ Enumerate processes. """ ... + def get_frontmost_application(self, scope: Optional[str] = None) -> Optional[Application]: """ Get details about the frontmost application. """ ... + def inject_library_blob(self, pid: int, blob_buffer: bytes, entrypoint: str, data: str) -> int: """ Inject a library blob to a PID. """ ... + def inject_library_file(self, pid: int, path: str, entrypoint: str, data: str) -> int: """ Inject a library file to a PID. """ ... + def input(self, pid: int, data: bytes) -> None: """ Input data on stdin of a spawned process. """ ... + def is_lost(self) -> bool: """ Query whether the device has been lost. """ ... + def kill(self, pid: int) -> None: """ Kill a PID. """ ... + def open_channel(self, address: str) -> "IOStream": """ Open a device-specific communication channel. """ ... + def unpair(self) -> None: """ Unpair device. """ ... + def query_system_parameters(self) -> Dict[str, Any]: """ Returns a dictionary of information about the host system. """ ... + def resume(self, pid: int) -> None: """ Resume a process from the attachable state. """ ... + def spawn( self, program: str, @@ -342,21 +388,25 @@ class DeviceManager(Object): Add a remote device. """ ... + def close(self) -> None: """ Close the device manager. """ ... + def enumerate_devices(self) -> List[Device]: """ Enumerate devices. """ ... + def get_device_matching(self, predicate: Callable[[Device], bool], timeout: int) -> Device: """ Get device matching predicate. """ ... + def remove_remote_device(self, address: str) -> None: """ Remove a remote device. @@ -371,6 +421,7 @@ class FileMonitor(Object): Disable the file monitor. """ ... + def enable(self) -> None: """ Enable the file monitor. @@ -383,26 +434,31 @@ class IOStream(Object): Close the stream. """ ... + def is_closed(self) -> bool: """ Query whether the stream is closed. """ ... + def read(self, size: int) -> bytes: """ Read up to the specified number of bytes from the stream. """ ... + def read_all(self, size: int) -> bytes: """ Read exactly the specified number of bytes from the stream. """ ... + def write(self, data: bytes) -> int: """ Write as much as possible of the provided data to the stream. """ ... + def write_all(self, data: bytes) -> None: """ Write all of the provided data to the stream. @@ -423,46 +479,55 @@ class PortalService(Object): Device for in-process control. """ ... + def broadcast(self, message: str, data: Optional[Union[str, bytes]] = None) -> None: """ Broadcast a message to all control channels. """ ... + def enumerate_tags(self, connection_id: int) -> List[str]: """ Enumerate tags of a specific connection. """ ... + def kick(self, connection_id: int) -> None: """ Kick out a specific connection. """ ... + def narrowcast(self, tag: str, message: str, data: Optional[Union[str, bytes]] = None) -> None: """ Post a message to control channels with a specific tag. """ ... + def post(self, connection_id: int, message: str, data: Optional[Union[str, bytes]] = None) -> None: """ Post a message to a specific control channel. """ ... + def start(self) -> None: """ Start listening for incoming connections. """ ... + def stop(self) -> None: """ Stop listening for incoming connections, and kick any connected clients. """ ... + def tag(self, connection_id: int, tag: str) -> None: """ Tag a specific control channel. """ ... + def untag(self, connection_id: int, tag: str) -> None: """ Untag a specific control channel. @@ -476,12 +541,14 @@ class Process(Object): Process ID. """ ... + @property def name(self) -> str: """ Human-readable process name. """ ... + @property def parameters(self) -> Dict[str, Any]: """ @@ -497,18 +564,21 @@ class Relay(Object): Network address or address:port of the TURN server. """ ... + @property def kind(self) -> str: """ Relay kind. One of: turn-udp, turn-tcp, turn-tls. """ ... + @property def password(self) -> str: """ The TURN password to use for the allocate request. """ ... + @property def username(self) -> str: """ @@ -522,31 +592,37 @@ class Script(Object): Eternalize the script. """ ... + def is_destroyed(self) -> bool: """ Query whether the script has been destroyed. """ ... + def load(self) -> None: """ Load the script. """ ... + def post(self, message: str, data: Optional[Union[str, bytes]] = None) -> None: """ Post a JSON-encoded message to the script. """ ... + def unload(self) -> None: """ Unload the script. """ ... + def enable_debugger(self, port: Optional[int]) -> None: """ Enable the Node.js compatible script debugger """ ... + def disable_debugger(self) -> None: """ Disable the Node.js compatible script debugger @@ -560,16 +636,19 @@ class Session(Object): Process ID. """ ... + def compile_script(self, source: str, name: Optional[str] = None, runtime: Optional[str] = None) -> bytes: """ Compile script source code to bytecode. """ ... + def create_script(self, source: str, name: Optional[str] = None, runtime: Optional[str] = None) -> Script: """ Create a new script. """ ... + def create_script_from_bytes( self, data: bytes, name: Optional[str] = None, runtime: Optional[str] = None ) -> Script: @@ -577,31 +656,37 @@ class Session(Object): Create a new script from bytecode. """ ... + def snapshot_script(self, embed_script: str, warmup_script: Optional[str], runtime: Optional[str] = None) -> bytes: """ Evaluate script and snapshot the resulting VM state """ ... + def detach(self) -> None: """ Detach session from the process. """ ... + def disable_child_gating(self) -> None: """ Disable child gating. """ ... + def enable_child_gating(self) -> None: """ Enable child gating. """ ... + def is_detached(self) -> bool: """ Query whether the session is detached. """ ... + def join_portal( self, address: str, certificate: Optional[str] = None, token: Optional[str] = None, acl: Optional[Any] = None ) -> PortalMembership: @@ -609,11 +694,13 @@ class Session(Object): Join a portal. """ ... + def resume(self) -> None: """ Resume session after network error. """ ... + def setup_peer_connection( self, stun_server: Optional[str] = None, relays: Optional[Sequence[Relay]] = None ) -> None: @@ -629,6 +716,7 @@ class Spawn(Object): Application identifier. """ ... + @property def pid(self) -> int: """ @@ -648,6 +736,7 @@ class Compiler(Object): Build an agent. """ ... + def watch( self, entrypoint: str, diff --git a/frida/core.py b/frida/core.py index d6746ab..90b5d23 100644 --- a/frida/core.py +++ b/frida/core.py @@ -334,16 +334,13 @@ def disable_debugger(self) -> None: self._impl.disable_debugger() @overload - def on(self, signal: Literal["destroyed"], callback: ScriptDestroyedCallback) -> None: - ... + def on(self, signal: Literal["destroyed"], callback: ScriptDestroyedCallback) -> None: ... @overload - def on(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: - ... + def on(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -356,16 +353,13 @@ def on(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.on(signal, callback) @overload - def off(self, signal: Literal["destroyed"], callback: ScriptDestroyedCallback) -> None: - ... + def off(self, signal: Literal["destroyed"], callback: ScriptDestroyedCallback) -> None: ... @overload - def off(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: - ... + def off(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -691,12 +685,10 @@ def on( self, signal: Literal["detached"], callback: SessionDetachedCallback, - ) -> None: - ... + ) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -710,12 +702,10 @@ def off( self, signal: Literal["detached"], callback: SessionDetachedCallback, - ) -> None: - ... + ) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -755,16 +745,13 @@ def post(self, message: Any, data: Optional[Union[str, bytes]] = None) -> None: self._impl.post(raw_message, **kwargs) @overload - def on(self, signal: Literal["detached"], callback: BusDetachedCallback) -> None: - ... + def on(self, signal: Literal["detached"], callback: BusDetachedCallback) -> None: ... @overload - def on(self, signal: Literal["message"], callback: BusMessageCallback) -> None: - ... + def on(self, signal: Literal["message"], callback: BusMessageCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -777,16 +764,13 @@ def on(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.on(signal, callback) @overload - def off(self, signal: Literal["detached"], callback: BusDetachedCallback) -> None: - ... + def off(self, signal: Literal["detached"], callback: BusDetachedCallback) -> None: ... @overload - def off(self, signal: Literal["message"], callback: BusMessageCallback) -> None: - ... + def off(self, signal: Literal["message"], callback: BusMessageCallback) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1052,40 +1036,31 @@ def get_bus(self) -> Bus: return self.bus @overload - def on(self, signal: Literal["spawn-added"], callback: DeviceSpawnAddedCallback) -> None: - ... + def on(self, signal: Literal["spawn-added"], callback: DeviceSpawnAddedCallback) -> None: ... @overload - def on(self, signal: Literal["spawn-removed"], callback: DeviceSpawnRemovedCallback) -> None: - ... + def on(self, signal: Literal["spawn-removed"], callback: DeviceSpawnRemovedCallback) -> None: ... @overload - def on(self, signal: Literal["child-added"], callback: DeviceChildAddedCallback) -> None: - ... + def on(self, signal: Literal["child-added"], callback: DeviceChildAddedCallback) -> None: ... @overload - def on(self, signal: Literal["child-removed"], callback: DeviceChildRemovedCallback) -> None: - ... + def on(self, signal: Literal["child-removed"], callback: DeviceChildRemovedCallback) -> None: ... @overload - def on(self, signal: Literal["process-crashed"], callback: DeviceProcessCrashedCallback) -> None: - ... + def on(self, signal: Literal["process-crashed"], callback: DeviceProcessCrashedCallback) -> None: ... @overload - def on(self, signal: Literal["output"], callback: DeviceOutputCallback) -> None: - ... + def on(self, signal: Literal["output"], callback: DeviceOutputCallback) -> None: ... @overload - def on(self, signal: Literal["uninjected"], callback: DeviceUninjectedCallback) -> None: - ... + def on(self, signal: Literal["uninjected"], callback: DeviceUninjectedCallback) -> None: ... @overload - def on(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: - ... + def on(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1095,40 +1070,31 @@ def on(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.on(signal, callback) @overload - def off(self, signal: Literal["spawn-added"], callback: DeviceSpawnAddedCallback) -> None: - ... + def off(self, signal: Literal["spawn-added"], callback: DeviceSpawnAddedCallback) -> None: ... @overload - def off(self, signal: Literal["spawn-removed"], callback: DeviceSpawnRemovedCallback) -> None: - ... + def off(self, signal: Literal["spawn-removed"], callback: DeviceSpawnRemovedCallback) -> None: ... @overload - def off(self, signal: Literal["child-added"], callback: DeviceChildAddedCallback) -> None: - ... + def off(self, signal: Literal["child-added"], callback: DeviceChildAddedCallback) -> None: ... @overload - def off(self, signal: Literal["child-removed"], callback: DeviceChildRemovedCallback) -> None: - ... + def off(self, signal: Literal["child-removed"], callback: DeviceChildRemovedCallback) -> None: ... @overload - def off(self, signal: Literal["process-crashed"], callback: DeviceProcessCrashedCallback) -> None: - ... + def off(self, signal: Literal["process-crashed"], callback: DeviceProcessCrashedCallback) -> None: ... @overload - def off(self, signal: Literal["output"], callback: DeviceOutputCallback) -> None: - ... + def off(self, signal: Literal["output"], callback: DeviceOutputCallback) -> None: ... @overload - def off(self, signal: Literal["uninjected"], callback: DeviceUninjectedCallback) -> None: - ... + def off(self, signal: Literal["uninjected"], callback: DeviceUninjectedCallback) -> None: ... @overload - def off(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: - ... + def off(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1239,20 +1205,16 @@ def remove_remote_device(self, address: str) -> None: self._impl.remove_remote_device(address=address) @overload - def on(self, signal: Literal["added"], callback: DeviceManagerAddedCallback) -> None: - ... + def on(self, signal: Literal["added"], callback: DeviceManagerAddedCallback) -> None: ... @overload - def on(self, signal: Literal["removed"], callback: DeviceManagerRemovedCallback) -> None: - ... + def on(self, signal: Literal["removed"], callback: DeviceManagerRemovedCallback) -> None: ... @overload - def on(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: - ... + def on(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1262,20 +1224,16 @@ def on(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.on(signal, callback) @overload - def off(self, signal: Literal["added"], callback: DeviceManagerAddedCallback) -> None: - ... + def off(self, signal: Literal["added"], callback: DeviceManagerAddedCallback) -> None: ... @overload - def off(self, signal: Literal["removed"], callback: DeviceManagerRemovedCallback) -> None: - ... + def off(self, signal: Literal["removed"], callback: DeviceManagerRemovedCallback) -> None: ... @overload - def off(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: - ... + def off(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1417,46 +1375,38 @@ def untag(self, connection_id: int, tag: str) -> None: self._impl.untag(connection_id, tag) @overload - def on(self, signal: Literal["node-joined"], callback: PortalServiceNodeJoinedCallback) -> None: - ... + def on(self, signal: Literal["node-joined"], callback: PortalServiceNodeJoinedCallback) -> None: ... @overload - def on(self, signal: Literal["node-left"], callback: PortalServiceNodeLeftCallback) -> None: - ... + def on(self, signal: Literal["node-left"], callback: PortalServiceNodeLeftCallback) -> None: ... @overload - def on(self, signal: Literal["controller-connected"], callback: PortalServiceControllerConnectedCallback) -> None: - ... + def on( + self, signal: Literal["controller-connected"], callback: PortalServiceControllerConnectedCallback + ) -> None: ... @overload def on( self, signal: Literal["controller-disconnected"], callback: PortalServiceControllerDisconnectedCallback - ) -> None: - ... + ) -> None: ... @overload - def on(self, signal: Literal["node-connected"], callback: PortalServiceNodeConnectedCallback) -> None: - ... + def on(self, signal: Literal["node-connected"], callback: PortalServiceNodeConnectedCallback) -> None: ... @overload - def on(self, signal: Literal["node-disconnected"], callback: PortalServiceNodeDisconnectedCallback) -> None: - ... + def on(self, signal: Literal["node-disconnected"], callback: PortalServiceNodeDisconnectedCallback) -> None: ... @overload - def on(self, signal: Literal["authenticated"], callback: PortalServiceAuthenticatedCallback) -> None: - ... + def on(self, signal: Literal["authenticated"], callback: PortalServiceAuthenticatedCallback) -> None: ... @overload - def on(self, signal: Literal["subscribe"], callback: PortalServiceSubscribeCallback) -> None: - ... + def on(self, signal: Literal["subscribe"], callback: PortalServiceSubscribeCallback) -> None: ... @overload - def on(self, signal: Literal["message"], callback: PortalServiceMessageCallback) -> None: - ... + def on(self, signal: Literal["message"], callback: PortalServiceMessageCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: """ @@ -1552,47 +1502,37 @@ def watch( return self._impl.watch(entrypoint, **kwargs) @overload - def on(self, signal: Literal["starting"], callback: CompilerStartingCallback) -> None: - ... + def on(self, signal: Literal["starting"], callback: CompilerStartingCallback) -> None: ... @overload - def on(self, signal: Literal["finished"], callback: CompilerFinishedCallback) -> None: - ... + def on(self, signal: Literal["finished"], callback: CompilerFinishedCallback) -> None: ... @overload - def on(self, signal: Literal["output"], callback: CompilerOutputCallback) -> None: - ... + def on(self, signal: Literal["output"], callback: CompilerOutputCallback) -> None: ... @overload - def on(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: - ... + def on(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: ... @overload - def on(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def on(self, signal: str, callback: Callable[..., Any]) -> None: ... def on(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.on(signal, callback) @overload - def off(self, signal: Literal["starting"], callback: CompilerStartingCallback) -> None: - ... + def off(self, signal: Literal["starting"], callback: CompilerStartingCallback) -> None: ... @overload - def off(self, signal: Literal["finished"], callback: CompilerFinishedCallback) -> None: - ... + def off(self, signal: Literal["finished"], callback: CompilerFinishedCallback) -> None: ... @overload - def off(self, signal: Literal["output"], callback: CompilerOutputCallback) -> None: - ... + def off(self, signal: Literal["output"], callback: CompilerOutputCallback) -> None: ... @overload - def off(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: - ... + def off(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: ... @overload - def off(self, signal: str, callback: Callable[..., Any]) -> None: - ... + def off(self, signal: str, callback: Callable[..., Any]) -> None: ... def off(self, signal: str, callback: Callable[..., Any]) -> None: self._impl.off(signal, callback) diff --git a/setup.py b/setup.py index 0d7c3a7..289a961 100644 --- a/setup.py +++ b/setup.py @@ -69,14 +69,16 @@ def detect_version() -> str: pkg_info = SOURCE_ROOT / "PKG-INFO" in_source_package = pkg_info.exists() if in_source_package: - version_line = [line for line in pkg_info.read_text(encoding="utf-8").split("\n") - if line.startswith("Version: ")][0].strip() + version_line = [ + line for line in pkg_info.read_text(encoding="utf-8").split("\n") if line.startswith("Version: ") + ][0].strip() version = version_line[9:] else: releng_location = next(enumerate_releng_locations(), None) if releng_location is not None: sys.path.insert(0, str(releng_location.parent)) from releng.frida_version import detect + version = detect(SOURCE_ROOT).name.replace("-dev.", ".dev") else: version = "0.0.0"