This is an automated email from the ASF dual-hosted git repository.

skrawcz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hamilton.git

commit 5f2c5adb0c627582f6ee44991384cc7b39e6a08d
Author: Stefan Krawczyk <[email protected]>
AuthorDate: Tue Feb 24 18:33:54 2026 -0800

    Address Dev-iL PR review comments: use pathlib.Path
    
    Changes based on PR #1488 review feedback:
    
    1. ui/backend/server/server/settings.py:
       - Replace os.path.exists/join with pathlib.Path operations
       - Use Path / operator instead of os.path.join
       - Convert to str() when needed for Django settings
    
    2. ui/backend/server/server/urls.py:
       - Remove unnecessary import os
       - Add from pathlib import Path
       - Replace os.path.exists/join with Path operations
       - Use Path / operator for path construction
    
    3. contrib/hamilton/contrib/dagworks/author.md:
       - Fix inconsistent line length formatting
    
    Benefits:
    - More Pythonic path handling
    - Prevents future ruff complaints about os.path usage
    - Consistent with modern Python best practices
    - Cleaner, more readable code
    
    Addresses review comments from @Dev-iL in PR #1488
---
 contrib/hamilton/contrib/dagworks/author.md |  6 +++---
 ui/backend/server/server/settings.py        | 10 +++++-----
 ui/backend/server/server/urls.py            | 16 +++++++---------
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/contrib/hamilton/contrib/dagworks/author.md 
b/contrib/hamilton/contrib/dagworks/author.md
index 9527e7e8..25f6ac26 100644
--- a/contrib/hamilton/contrib/dagworks/author.md
+++ b/contrib/hamilton/contrib/dagworks/author.md
@@ -22,6 +22,6 @@ title: DAGWorks
 ---
 # Officially maintained Apache Hamilton dataflows
 
-Here you'll find dataflows that are officially maintained by the Apache 
Hamilton github/mailing lists. Popular
-user-contributed dataflows will be moved here as necessary to support their 
continued
-development and maintenance.
+Here you'll find dataflows that are officially maintained by the Apache 
Hamilton
+github/mailing lists. Popular user-contributed dataflows will be moved here as
+necessary to support their continued development and maintenance.
diff --git a/ui/backend/server/server/settings.py 
b/ui/backend/server/server/settings.py
index 09fb03dd..5d3066dc 100644
--- a/ui/backend/server/server/settings.py
+++ b/ui/backend/server/server/settings.py
@@ -150,13 +150,13 @@ if HAMILTON_ENV == "mini":
     STATIC_URL = "/static/"
     # Support both Vite (assets/) and CRA (static/) build outputs
     staticfiles_dirs = []
-    if os.path.exists(os.path.join(BASE_DIR, "build/assets/")):
-        staticfiles_dirs.append(os.path.join(BASE_DIR, "build/assets/"))
-    if os.path.exists(os.path.join(BASE_DIR, "build/static/")):
-        staticfiles_dirs.append(os.path.join(BASE_DIR, "build/static/"))
+    if (BASE_DIR / "build/assets/").exists():
+        staticfiles_dirs.append(str(BASE_DIR / "build/assets/"))
+    if (BASE_DIR / "build/static/").exists():
+        staticfiles_dirs.append(str(BASE_DIR / "build/static/"))
     STATICFILES_DIRS = staticfiles_dirs
     MEDIA_URL = "/media/"
-    MEDIA_ROOT = os.path.join(BASE_DIR, "build/")
+    MEDIA_ROOT = str(BASE_DIR / "build/")
 
 # Database
 # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
diff --git a/ui/backend/server/server/urls.py b/ui/backend/server/server/urls.py
index 71cdc861..cf34ab03 100644
--- a/ui/backend/server/server/urls.py
+++ b/ui/backend/server/server/urls.py
@@ -43,15 +43,13 @@ from . import api, default_views
 if settings.HAMILTON_ENV == "mini":
     # mini-mode
     # TODO -- do meda assets correctly -- this just hardcodes logo.png for now
-    import os
-
     urlpatterns = [
         path("api/", api.api.urls),
         path("admin/", admin.site.urls),
     ]
 
     # Serve root-level assets from build/ directory
-    build_dir = os.path.join(settings.BASE_DIR, "build/")
+    build_dir = settings.BASE_DIR / "build/"
     root_assets = [
         "manifest.json",
         "robots.txt",
@@ -61,27 +59,27 @@ if settings.HAMILTON_ENV == "mini":
         "logo_with_text.svg",
     ]
     for asset in root_assets:
-        if os.path.exists(os.path.join(build_dir, asset)):
+        if (build_dir / asset).exists():
             urlpatterns.append(
-                re_path(rf"^{asset}$", serve, {"document_root": build_dir, 
"path": asset})
+                re_path(rf"^{asset}$", serve, {"document_root": 
str(build_dir), "path": asset})
             )
 
     # Serve static assets from build/assets/ (Vite) or build/static/ (CRA)
     # This MUST come before the catch-all route
-    if os.path.exists(os.path.join(settings.BASE_DIR, "build/assets/")):
+    if (settings.BASE_DIR / "build/assets/").exists():
         urlpatterns.append(
             re_path(
                 r"^assets/(?P<path>.*)$",
                 serve,
-                {"document_root": os.path.join(settings.BASE_DIR, 
"build/assets/")},
+                {"document_root": str(settings.BASE_DIR / "build/assets/")},
             )
         )
-    if os.path.exists(os.path.join(settings.BASE_DIR, "build/static/")):
+    if (settings.BASE_DIR / "build/static/").exists():
         urlpatterns.append(
             re_path(
                 r"^static/(?P<path>.*)$",
                 serve,
-                {"document_root": os.path.join(settings.BASE_DIR, 
"build/static/")},
+                {"document_root": str(settings.BASE_DIR / "build/static/")},
             )
         )
 

Reply via email to