From b867981c73925453ce5f4c933d40cf0f5aca5236 Mon Sep 17 00:00:00 2001 From: Tom JEANNESSON Date: Wed, 30 Oct 2024 20:47:13 +0100 Subject: [PATCH 1/2] fix(bridge): circular imports --- backend/nango/bridge/bridge.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/nango/bridge/bridge.py b/backend/nango/bridge/bridge.py index 0c11aea..575d7be 100644 --- a/backend/nango/bridge/bridge.py +++ b/backend/nango/bridge/bridge.py @@ -191,8 +191,15 @@ def make_serializer_file( # Build customizable user's serializer nango_serializer_name: str = f"{model_name}{'Detail' if detail else ''}NangoSerializer" + regex = r"(?<=')(.*)(?=\.)" + match = re.search(regex, str(model)) + import_path = match.group(1) data = { - "imports": [f"from api._nango_cache.{snake_case_model_name} import {nango_serializer_name}"], + "imports": [ + f"from api._nango_cache.{snake_case_model_name}.{snake_case_model_name}{"_detail" if detail else ""}" + f"_nango_serializer import {nango_serializer_name}", + f"from {import_path} import {model_name}", + ], "model_name": model_name, "serializer_name": f"{model_name}{'Detail' if detail else ''}Serializer", "nango_serializer": nango_serializer_name, @@ -200,10 +207,6 @@ def make_serializer_file( self._make_serializer(folder_path=self.api_folder_path / snake_case_model_name, data=data, detail=detail) # Build generated Nango's serializer - regex = r"(?<=')(.*)(?=\.)" - match = re.search(regex, str(model)) - import_path = match.group(1) - data = { "imports": [ f"from {import_path} import {model_name}", @@ -231,7 +234,8 @@ def make_serializer_file( ], } data["imports"] = [ - f"from api.{dico.get('model_name')}.{from_camelcase_to_snakecase(dico.get('model_name'))}_serializer import {dico.get('serializer')}" + f"from api.{from_camelcase_to_snakecase(dico.get('model_name'))}.{from_camelcase_to_snakecase(dico.get('model_name'))}" + f"_serializer import {dico.get('serializer')}" for dico in data["detail"]["specified_fields"] ] + data["imports"] else: From 6b28370d620c8483542e2339a233ab5fb8a78574 Mon Sep 17 00:00:00 2001 From: Tom JEANNESSON Date: Wed, 30 Oct 2024 20:51:58 +0100 Subject: [PATCH 2/2] Minor commit @ Mer 30 oct 2024 20:46:23 CET --- .github/workflows/django.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 0a5f77b..922949a 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -32,7 +32,7 @@ jobs: - name: Create ./backend/.envs/.development files run: | - python -m pip install cryptography + python -m pip install cryptography ruff python ./setup/env_file_generator.py development - name: Start containers