From 0c903b0151f018e44738a8ec78b707ca2f287963 Mon Sep 17 00:00:00 2001 From: Matteo Ferrando Date: Wed, 30 Oct 2024 09:38:02 -0400 Subject: [PATCH] removeprefix --- projects/fal/src/fal/apps.py | 6 ++++-- projects/fal/src/fal/workflows.py | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/projects/fal/src/fal/apps.py b/projects/fal/src/fal/apps.py index ba1465f5..208b7491 100644 --- a/projects/fal/src/fal/apps.py +++ b/projects/fal/src/fal/apps.py @@ -173,7 +173,8 @@ 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("/") + _path = path[len("/") :] if path.startswith("/") else path + url += "/" + _path creds = get_default_credentials() @@ -235,7 +236,8 @@ 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("/") + _path = path[len("/") :] if path.startswith("/") else path + url += "/" + _path creds = get_default_credentials() diff --git a/projects/fal/src/fal/workflows.py b/projects/fal/src/fal/workflows.py index f193d52a..62c50ebf 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))