Skip to content

Commit 1540d22

Browse files
committed
fix(vite): remove unused ViteConfig import post-generation
1 parent f7278bf commit 1540d22

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/Litestar/Plugins/LitestarVite/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def _update_app_config(self, app_path: Path) -> None:
3636
if "from config import settings" in content and "vite_config" not in content:
3737
content = content.replace("from config import settings", "from config import settings, vite_config")
3838

39+
if "from litestar_vite import ViteConfig, VitePlugin" in content:
40+
content = content.replace(
41+
"from litestar_vite import ViteConfig, VitePlugin",
42+
"from litestar_vite import VitePlugin",
43+
)
44+
3945
# Update plugin config
4046
bootstrap_config = "VitePlugin(config=ViteConfig(dev_mode=settings.DEBUG))"
4147
full_config = "VitePlugin(config=vite_config)"

tests/test_vite_lifecycle.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1+
import pytest
12
from pathlib import Path
23
from textwrap import dedent
34

4-
import pytest
5-
65
from src.Litestar.Plugins.LitestarVite import LitestarVitePlugin
76

87

98
@pytest.fixture
10-
def app_file(tmp_path: Path) -> Path:
11-
"""Create a temporary app.py file with bootstrap configuration.
12-
13-
Returns:
14-
Path to the created app.py file.
15-
16-
"""
9+
def app_file(tmp_path):
10+
"""Create a temporary app.py file with bootstrap configuration."""
1711
content = dedent("""
1812
from litestar import Litestar
1913
from config import settings
@@ -40,6 +34,8 @@ def test_update_app_config(app_file: Path) -> None:
4034

4135
# Check imports
4236
assert "from config import settings, vite_config" in updated_content
37+
assert "from litestar_vite import VitePlugin" in updated_content
38+
assert "from litestar_vite import ViteConfig, VitePlugin" not in updated_content
4339

4440
# Check plugin config
4541
assert "VitePlugin(config=vite_config)" in updated_content

0 commit comments

Comments
 (0)