From f3ad6fadbc12d21a52a8c7976c5e9c7c15f76528 Mon Sep 17 00:00:00 2001 From: Matteo Ferrando <matteo.ferrando2@gmail.com> Date: Wed, 30 Oct 2024 09:38:02 -0400 Subject: [PATCH] removeprefix --- projects/fal/src/fal/apps.py | 4 ++-- projects/fal/src/fal/workflows.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/projects/fal/src/fal/apps.py b/projects/fal/src/fal/apps.py index ba1465f5..d33cb3c9 100644 --- a/projects/fal/src/fal/apps.py +++ b/projects/fal/src/fal/apps.py @@ -173,7 +173,7 @@ def submit(app_id: str, arguments: dict[str, Any], *, path: str = "") -> Request app_id = _backwards_compatible_app_id(app_id) url = _QUEUE_URL_FORMAT.format(app_id=app_id) if path: - url += "/" + path.removeprefix("/") + url += path if path.startswith("/") else "/" + path creds = get_default_credentials() @@ -235,7 +235,7 @@ def _connect(app_id: str, *, path: str = "/realtime") -> Iterator[_RealtimeConne app_id = _backwards_compatible_app_id(app_id) url = _REALTIME_URL_FORMAT.format(app_id=app_id) if path: - url += "/" + path.removeprefix("/") + url += path if path.startswith("/") else "/" + path creds = get_default_credentials() diff --git a/projects/fal/src/fal/workflows.py b/projects/fal/src/fal/workflows.py index f193d52a..ba338ec8 100644 --- a/projects/fal/src/fal/workflows.py +++ b/projects/fal/src/fal/workflows.py @@ -50,7 +50,13 @@ def parse_leaf(raw_leaf: str) -> Leaf: f"Invalid leaf: {raw_leaf} (must start with a reference)" ) - leaf: Leaf = ReferenceLeaf(reference.removeprefix(VARIABLE_PREFIX)) + # remove the $ prefix + reference = ( + reference[len(VARIABLE_PREFIX) :] + if reference.startswith(VARIABLE_PREFIX) + else reference + ) + leaf: Leaf = ReferenceLeaf(reference) for raw_part in raw_parts: if raw_part.isdigit(): leaf = IndexLeaf(leaf, int(raw_part))