AnswerDotAI / AnswerDotAI/fasthtml

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

Open
#822 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Jupyter Notebook
Stars
7k
Forks
319
Avg merge
28m
Merged PRs (30d)
3

Description

**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 *](https://www.fastht.ml/docs/explains/faq.html#why-use-import)

**Minimal Reproducible Example**
```python
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**
```python
----> 5 db_path.exists()

TypeError: 'NoneType' object is not callable
```

**Additional debug info**
```python
print(Path) #
print(type(db_path)) #
```

**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)
- [x] I have provided a minimal reproducible example
- [x] I have included the versions of fastlite, fastcore, and fasthtml
- [x] 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:
```python
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.:
```python
/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/ :
```python
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**
-

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.