refactor: move Python packages under python_pkg/

- Move puzzle_solver/, poker_modifier_app/, articles/, tests/ into python_pkg/
- Move moviepy_showcase.py and _moviepy_*.py into python_pkg/moviepy_showcase/
- Update all imports to use python_pkg. prefix
- Update pyproject.toml per-file-ignores and pytest testpaths
- Add pre-commit hook to enforce Python files under python_pkg/
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-03-18 22:54:45 +01:00
parent 21b7b8107b
commit 72c6c3788c
40 changed files with 78 additions and 22 deletions

View File

@ -357,6 +357,17 @@ repos:
types_or: [c, c++]
exclude: ^CPP/mini_browser/
# ===========================================================================
# CHECK PYTHON LOCATION - All Python files must be under python_pkg/
# ===========================================================================
- repo: local
hooks:
- id: check-python-location
name: check Python files are under python_pkg/
entry: scripts/check_python_location.sh
language: script
types: [python]
# ===========================================================================
# REMOVE EMPTY DIRECTORIES - Clean up empty folders in the repo
# ===========================================================================

View File

@ -66,10 +66,10 @@ unfixable = []
# Files using urlopen with validated URL schemes
"python_pkg/geo_data/_common.py" = ["S310"]
"python_pkg/steam_backlog_enforcer/library_hider.py" = ["S310"]
"poker_modifier_app/poker_modifier_app.py" = [
"python_pkg/poker_modifier_app/poker_modifier_app.py" = [
"FBT003", # Boolean positional values in tkinter API calls
]
"poker_modifier_app/_poker_gui.py" = [
"python_pkg/poker_modifier_app/_poker_gui.py" = [
"FBT003", # Boolean positional values in tkinter API calls
]
"python_pkg/keyboard_coop/main.py" = [
@ -102,12 +102,11 @@ unfixable = []
"PLC0415", # Lazy imports of split helper modules
]
# Moviepy showcase - lazy imports of split helpers
"moviepy_showcase.py" = [
"INP001",
"python_pkg/moviepy_showcase/moviepy_showcase.py" = [
"PLC0415", # Lazy imports of split helper modules
]
# Puzzle solver - late imports for CLI entry point
"puzzle_solver/main.py" = [
"python_pkg/puzzle_solver/main.py" = [
"PLC0415", # Late imports in __main__ guard
]
# Geo data admin helper
@ -125,9 +124,7 @@ unfixable = []
"python_pkg/praca_magisterska_video/visualize_q02.py" = [
"PLC0415", # Late import for conditional dependency
]
# Root-level helper scripts and test files outside packages
"_moviepy_*.py" = ["INP001"]
"tests/test_file_length.py" = ["INP001"]
# Removed: root-level moviepy helper scripts and test files are now inside python_pkg
"python_pkg/word_frequency/_translator_cli.py" = [
"SLF001", # Legitimately accesses translator module internals
]
@ -251,7 +248,7 @@ exclude_dirs = ["tests", ".venv", "Bash/ffmpeg-build", "python_pkg/lichess_bot/.
# PYTEST - Testing framework configuration
# ============================================================================
[tool.pytest.ini_options]
testpaths = ["tests", "python_pkg", "articles"]
testpaths = ["python_pkg"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]

View File

@ -0,0 +1 @@
"""MoviePy 2.x comprehensive showcase package."""

View File

@ -31,7 +31,7 @@ from moviepy.video.tools.drawing import (
)
import numpy as np
from moviepy_showcase import (
from python_pkg.moviepy_showcase.moviepy_showcase import (
CLIP_DUR,
FONT_B,
FONT_R,

View File

@ -18,7 +18,7 @@ from moviepy.video.fx import InvertColors
from moviepy.video.tools.drawing import circle
import numpy as np
from moviepy_showcase import (
from python_pkg.moviepy_showcase.moviepy_showcase import (
CLIP_DUR,
FONT_B,
FONT_R,

View File

@ -45,7 +45,7 @@ from moviepy.video.fx import (
from moviepy.video.tools.drawing import circle
import numpy as np
from moviepy_showcase import (
from python_pkg.moviepy_showcase.moviepy_showcase import (
CLIP_DUR,
H,
W,

View File

@ -197,18 +197,18 @@ def _build(tmpdir: str) -> None:
# ── Lazy imports of moved part builders ───────────────────────
from moviepy.audio.fx import MultiplyVolume
from _moviepy_audio_output import (
from python_pkg.moviepy_showcase._moviepy_audio_output import (
_make_sine,
part4_audio,
part5_composition,
part6_drawing_tools,
part7_output,
)
from _moviepy_clip_types import (
from python_pkg.moviepy_showcase._moviepy_clip_types import (
part1_clip_types,
part2_clip_methods,
)
from _moviepy_video_effects import part3_video_effects
from python_pkg.moviepy_showcase._moviepy_video_effects import part3_video_effects
# ── Render each part to its own temp file ─────────────────────
# Title card

View File

@ -7,7 +7,7 @@ from tkinter import ttk
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from poker_modifier_app.poker_modifier_app import PokerModifierApp
from python_pkg.poker_modifier_app.poker_modifier_app import PokerModifierApp
class PokerGuiMixin:

View File

@ -4,8 +4,11 @@ import logging
import secrets
import tkinter as tk
from poker_modifier_app._poker_gui import PokerGuiMixin
from poker_modifier_app._poker_modifiers import ENDGAME_MODIFIERS, REGULAR_MODIFIERS
from python_pkg.poker_modifier_app._poker_gui import PokerGuiMixin
from python_pkg.poker_modifier_app._poker_modifiers import (
ENDGAME_MODIFIERS,
REGULAR_MODIFIERS,
)
_logger = logging.getLogger(__name__)

View File

@ -1,5 +1,5 @@
"""Allow ``python -m puzzle_solver …`` invocation."""
from puzzle_solver.main import main
from python_pkg.puzzle_solver.main import main
main()

View File

@ -22,8 +22,8 @@ import json
from pathlib import Path
import sys
from puzzle_solver.parse_image import draw_debug, parse_image, save_puzzle
from puzzle_solver.solver import Puzzle, print_puzzle, print_solution, solve
from python_pkg.puzzle_solver.parse_image import draw_debug, parse_image, save_puzzle
from python_pkg.puzzle_solver.solver import Puzzle, print_puzzle, print_solution, solve
def cmd_parse(args: argparse.Namespace) -> None:

View File

@ -0,0 +1 @@
"""Repository-wide tests package."""

View File

@ -20,7 +20,7 @@ _SKIP_DIRS = frozenset(
}
)
_ROOT = Path(__file__).resolve().parents[1]
_ROOT = Path(__file__).resolve().parents[2]
def _python_files() -> list[Path]:

View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Check that all Python files are under python_pkg/.
# Exceptions: linux_configuration/, pomodoro_app/, sonic_pi/, Bash/,
# and vendored/generated directories.
# Used as a pre-commit hook; receives staged file paths as arguments.
set -uo pipefail
# Directories allowed to contain Python files outside python_pkg/
ALLOWED_DIRS="linux_configuration/|pomodoro_app/|sonic_pi/"
errors=()
for file in "$@"; do
# Only check .py files
[[ "$file" != *.py ]] && continue
# Skip files already under python_pkg/
[[ "$file" == python_pkg/* ]] && continue
# Skip allowed directories (non-Python projects with some Python scripts)
if echo "$file" | grep -qE "^($ALLOWED_DIRS)"; then
continue
fi
# Skip vendored/generated directories
if echo "$file" | grep -qE '(^|/)(\.venv|venv|__pycache__|build|dist|node_modules|\.git)/'; then
continue
fi
errors+=("$file")
done
if [[ ${#errors[@]} -gt 0 ]]; then
echo "ERROR: Python files must be under python_pkg/."
echo "The following files are in the wrong location:"
for err in "${errors[@]}"; do
echo " $err"
done
echo ""
echo "Move them with: git mv <file> python_pkg/<file>"
exit 1
fi