mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 13:03:13 +02:00
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:
parent
21b7b8107b
commit
72c6c3788c
@ -357,6 +357,17 @@ repos:
|
|||||||
types_or: [c, c++]
|
types_or: [c, c++]
|
||||||
exclude: ^CPP/mini_browser/
|
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
|
# REMOVE EMPTY DIRECTORIES - Clean up empty folders in the repo
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|||||||
@ -66,10 +66,10 @@ unfixable = []
|
|||||||
# Files using urlopen with validated URL schemes
|
# Files using urlopen with validated URL schemes
|
||||||
"python_pkg/geo_data/_common.py" = ["S310"]
|
"python_pkg/geo_data/_common.py" = ["S310"]
|
||||||
"python_pkg/steam_backlog_enforcer/library_hider.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
|
"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
|
"FBT003", # Boolean positional values in tkinter API calls
|
||||||
]
|
]
|
||||||
"python_pkg/keyboard_coop/main.py" = [
|
"python_pkg/keyboard_coop/main.py" = [
|
||||||
@ -102,12 +102,11 @@ unfixable = []
|
|||||||
"PLC0415", # Lazy imports of split helper modules
|
"PLC0415", # Lazy imports of split helper modules
|
||||||
]
|
]
|
||||||
# Moviepy showcase - lazy imports of split helpers
|
# Moviepy showcase - lazy imports of split helpers
|
||||||
"moviepy_showcase.py" = [
|
"python_pkg/moviepy_showcase/moviepy_showcase.py" = [
|
||||||
"INP001",
|
|
||||||
"PLC0415", # Lazy imports of split helper modules
|
"PLC0415", # Lazy imports of split helper modules
|
||||||
]
|
]
|
||||||
# Puzzle solver - late imports for CLI entry point
|
# Puzzle solver - late imports for CLI entry point
|
||||||
"puzzle_solver/main.py" = [
|
"python_pkg/puzzle_solver/main.py" = [
|
||||||
"PLC0415", # Late imports in __main__ guard
|
"PLC0415", # Late imports in __main__ guard
|
||||||
]
|
]
|
||||||
# Geo data admin helper
|
# Geo data admin helper
|
||||||
@ -125,9 +124,7 @@ unfixable = []
|
|||||||
"python_pkg/praca_magisterska_video/visualize_q02.py" = [
|
"python_pkg/praca_magisterska_video/visualize_q02.py" = [
|
||||||
"PLC0415", # Late import for conditional dependency
|
"PLC0415", # Late import for conditional dependency
|
||||||
]
|
]
|
||||||
# Root-level helper scripts and test files outside packages
|
# Removed: root-level moviepy helper scripts and test files are now inside python_pkg
|
||||||
"_moviepy_*.py" = ["INP001"]
|
|
||||||
"tests/test_file_length.py" = ["INP001"]
|
|
||||||
"python_pkg/word_frequency/_translator_cli.py" = [
|
"python_pkg/word_frequency/_translator_cli.py" = [
|
||||||
"SLF001", # Legitimately accesses translator module internals
|
"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
|
# PYTEST - Testing framework configuration
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
testpaths = ["tests", "python_pkg", "articles"]
|
testpaths = ["python_pkg"]
|
||||||
python_files = ["test_*.py", "*_test.py"]
|
python_files = ["test_*.py", "*_test.py"]
|
||||||
python_classes = ["Test*"]
|
python_classes = ["Test*"]
|
||||||
python_functions = ["test_*"]
|
python_functions = ["test_*"]
|
||||||
|
|||||||
1
python_pkg/moviepy_showcase/__init__.py
Normal file
1
python_pkg/moviepy_showcase/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""MoviePy 2.x comprehensive showcase package."""
|
||||||
@ -31,7 +31,7 @@ from moviepy.video.tools.drawing import (
|
|||||||
)
|
)
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from moviepy_showcase import (
|
from python_pkg.moviepy_showcase.moviepy_showcase import (
|
||||||
CLIP_DUR,
|
CLIP_DUR,
|
||||||
FONT_B,
|
FONT_B,
|
||||||
FONT_R,
|
FONT_R,
|
||||||
@ -18,7 +18,7 @@ from moviepy.video.fx import InvertColors
|
|||||||
from moviepy.video.tools.drawing import circle
|
from moviepy.video.tools.drawing import circle
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from moviepy_showcase import (
|
from python_pkg.moviepy_showcase.moviepy_showcase import (
|
||||||
CLIP_DUR,
|
CLIP_DUR,
|
||||||
FONT_B,
|
FONT_B,
|
||||||
FONT_R,
|
FONT_R,
|
||||||
@ -45,7 +45,7 @@ from moviepy.video.fx import (
|
|||||||
from moviepy.video.tools.drawing import circle
|
from moviepy.video.tools.drawing import circle
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from moviepy_showcase import (
|
from python_pkg.moviepy_showcase.moviepy_showcase import (
|
||||||
CLIP_DUR,
|
CLIP_DUR,
|
||||||
H,
|
H,
|
||||||
W,
|
W,
|
||||||
@ -197,18 +197,18 @@ def _build(tmpdir: str) -> None:
|
|||||||
# ── Lazy imports of moved part builders ───────────────────────
|
# ── Lazy imports of moved part builders ───────────────────────
|
||||||
from moviepy.audio.fx import MultiplyVolume
|
from moviepy.audio.fx import MultiplyVolume
|
||||||
|
|
||||||
from _moviepy_audio_output import (
|
from python_pkg.moviepy_showcase._moviepy_audio_output import (
|
||||||
_make_sine,
|
_make_sine,
|
||||||
part4_audio,
|
part4_audio,
|
||||||
part5_composition,
|
part5_composition,
|
||||||
part6_drawing_tools,
|
part6_drawing_tools,
|
||||||
part7_output,
|
part7_output,
|
||||||
)
|
)
|
||||||
from _moviepy_clip_types import (
|
from python_pkg.moviepy_showcase._moviepy_clip_types import (
|
||||||
part1_clip_types,
|
part1_clip_types,
|
||||||
part2_clip_methods,
|
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 ─────────────────────
|
# ── Render each part to its own temp file ─────────────────────
|
||||||
# Title card
|
# Title card
|
||||||
@ -7,7 +7,7 @@ from tkinter import ttk
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if 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:
|
class PokerGuiMixin:
|
||||||
@ -4,8 +4,11 @@ import logging
|
|||||||
import secrets
|
import secrets
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
from poker_modifier_app._poker_gui import PokerGuiMixin
|
from python_pkg.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_modifiers import (
|
||||||
|
ENDGAME_MODIFIERS,
|
||||||
|
REGULAR_MODIFIERS,
|
||||||
|
)
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
"""Allow ``python -m puzzle_solver …`` invocation."""
|
"""Allow ``python -m puzzle_solver …`` invocation."""
|
||||||
|
|
||||||
from puzzle_solver.main import main
|
from python_pkg.puzzle_solver.main import main
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@ -22,8 +22,8 @@ import json
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from puzzle_solver.parse_image import draw_debug, parse_image, save_puzzle
|
from python_pkg.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.solver import Puzzle, print_puzzle, print_solution, solve
|
||||||
|
|
||||||
|
|
||||||
def cmd_parse(args: argparse.Namespace) -> None:
|
def cmd_parse(args: argparse.Namespace) -> None:
|
||||||
1
python_pkg/tests/__init__.py
Normal file
1
python_pkg/tests/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Repository-wide tests package."""
|
||||||
@ -20,7 +20,7 @@ _SKIP_DIRS = frozenset(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_ROOT = Path(__file__).resolve().parents[1]
|
_ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
|
|
||||||
def _python_files() -> list[Path]:
|
def _python_files() -> list[Path]:
|
||||||
43
scripts/check_python_location.sh
Executable file
43
scripts/check_python_location.sh
Executable 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
|
||||||
Loading…
Reference in New Issue
Block a user