Skip to content

[BUG] from fasthtml.svg import *'s Path competes with pathlib's Path #822

@NumesSanguis

Description

@NumesSanguis

Describe the bug
Pathlib is a popular library in standard Python. A common way to use it, is through importing it with from pathlib import Path. However, this competes with * import of fasthtml.svg.

This violates the assumption that "there’s no risk of namespace pollution." as mentioned in the FAQ: Why use import *

Minimal Reproducible Example

from pathlib import Path
from fasthtml.svg import *

db_path = Path("my.db")
db_path.exists()

Expected behavior
Output False or True as by Path.exists() functionality,

Actual behavior

----> 5 db_path.exists()

TypeError: 'NoneType' object is not callable

Additional debug info

print(Path)  # <function Path at 0x77f6e2564f40>
print(type(db_path))  # <class 'fasthtml.svg.PathFT'>

Environment Information
Please provide the following version information:

  • fastlite version: 0.2.4
  • fastcore version: 1.11.3
  • fasthtml version: 0.12.39
  • SolveIt platform (2026.01.13)

Confirmation
Please confirm the following:

  • [broken link] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • I have provided a minimal reproducible example
  • I have included the versions of fastlite, fastcore, and fasthtml
  • I understand that this is a volunteer open source project with no commercial support.

Additional context
I was using https://h2f.answer.ai/ to change DaisyUI components into Python code. I needed to import fasthtml.svg for the SVG components to work, but then I ran into an issue when trying to open a SQLite database through the fastlite library.

Imperfect Workaround
Reverse import:

from fasthtml.svg import *
from pathlib import Path

db_path = Path("my.db")
db_path.exists()
# False

resolves the issue, but then you get a silent error when using SVG's Path (e.g.:

/tmp/ipykernel_738/1475374686.py:16: DeprecationWarning: support for supplying keyword arguments to pathlib.PurePath is deprecated and scheduled for removal in Python 3.14
  Path(d='M6 3L20 12 6 21 6 3z')

e.g. when using https://daisyui.com/components/list/ through https://h2f.answer.ai/ :

preview(Ul(cls='list bg-base-100 rounded-box shadow-md')(
    Li('Most played songs this week', cls='p-4 pb-2 text-xs opacity-60 tracking-wide'),
    Li(cls='list-row')(
        Div(
            Img(src='https://img.daisyui.com/images/profile/demo/1@94.webp', cls='size-10 rounded-box')
        ),
        Div(
            Div('Dio Lupa'),
            Div('Remaining Reason', cls='text-xs uppercase font-semibold opacity-60')
        ),
        Button(cls='btn btn-square btn-ghost')(
            Svg(xmlns='http://www.w3.org/2000/svg', viewbox='0 0 24 24', cls='size-[1.2em]')(
                G(stroke_linejoin='round', stroke_linecap='round', stroke_width='2', fill='none', stroke='currentColor')(
                    Path(d='M6 3L20 12 6 21 6 3z')
                )
            )
        )
    )
))

Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions