Skip to content

Commit 0df34be

Browse files
chrisdpurcellclaude
andcommitted
fix: update run command to python -m src.main with sys.path guard
Adds src/__init__.py to make the package importable. Updates CLAUDE.md run example to use -m invocation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d07c9d commit 0df34be

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ TextTools is a PySide6 desktop application for text processing on Linux. Its pla
1111
## Commands
1212

1313
```bash
14-
# Run the application
15-
python src/main.py
14+
# Run the application (must be run from project root)
15+
python -m src.main
1616

1717
# Run all tests (coverage is on by default via pyproject.toml addopts)
1818
pytest tests/

src/__init__.py

Whitespace-only changes.

src/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66

77
import logging
88
import sys
9+
from pathlib import Path
910

10-
from PySide6.QtWidgets import QApplication
11+
# Insert project root so `from src.xxx` imports resolve regardless of how the
12+
# script is invoked (python src/main.py, python -m src.main, full path, IDE).
13+
_project_root = Path(__file__).resolve().parent.parent
14+
if str(_project_root) not in sys.path:
15+
sys.path.insert(0, str(_project_root))
1116

12-
from src.services.file_service import FileService
13-
from src.services.text_processing_service import TextProcessingService
14-
from src.utils.constants import APP_NAME, APP_VERSION
15-
from src.viewmodels.main_viewmodel import MainViewModel
16-
from src.views.main_window import MainWindow
17+
from PySide6.QtWidgets import QApplication # noqa: E402
18+
19+
from src.services.file_service import FileService # noqa: E402
20+
from src.services.text_processing_service import TextProcessingService # noqa: E402
21+
from src.utils.constants import APP_NAME, APP_VERSION # noqa: E402
22+
from src.viewmodels.main_viewmodel import MainViewModel # noqa: E402
23+
from src.views.main_window import MainWindow # noqa: E402
1724

1825
logging.basicConfig(
1926
level=logging.INFO,

0 commit comments

Comments
 (0)