Skip to content

Commit 47522a7

Browse files
committed
Add typing fixes, import cleanup, and staticmethod
Update type hints and imports across several modules: splash.py now uses union return types (QPixmap | None, QSplashScreen | None) to reflect possible None returns; processor_utils.py adds from __future__ import annotations, imports import_module and replaces importlib.import_module calls for clearer imports; display.py marks BBoxColors.get_all_display_names as @staticmethod. These changes improve typing clarity and minor API correctness.
1 parent 28e4e9e commit 47522a7

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

dlclivegui/gui/misc/splash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SplashConfig:
1919
bg_color = Qt.black # Fallback background color when image is missing
2020

2121

22-
def build_splash_pixmap(cfg: SplashConfig) -> QPixmap:
22+
def build_splash_pixmap(cfg: SplashConfig) -> QPixmap | None:
2323
"""
2424
Build a splash pixmap from config. If the image is invalid, returns a filled pixmap
2525
with fallback size and background color.
@@ -35,7 +35,7 @@ def build_splash_pixmap(cfg: SplashConfig) -> QPixmap:
3535
return None
3636

3737

38-
def show_splash(cfg: SplashConfig) -> QSplashScreen:
38+
def show_splash(cfg: SplashConfig) -> QSplashScreen | None:
3939
"""
4040
Create and show the splash screen from config. Returns the QSplashScreen instance.
4141
The caller is responsible for closing it.

dlclivegui/processors/processor_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from __future__ import annotations
2+
13
import importlib.util
24
import inspect
35
import logging
46
import pkgutil
57
import sys
8+
from importlib import import_module
69
from importlib.resources import as_file, files
710
from pathlib import Path
811

@@ -45,7 +48,7 @@ def scan_processor_package(package_name: str = "dlclivegui.processors") -> dict[
4548
all_processors: dict[str, dict] = {}
4649

4750
try:
48-
pkg = importlib.import_module(package_name)
51+
pkg = import_module(package_name)
4952
except Exception:
5053
logger.exception(f"Could not import package '{package_name}'")
5154
return all_processors
@@ -55,7 +58,7 @@ def scan_processor_package(package_name: str = "dlclivegui.processors") -> dict[
5558
if ispkg:
5659
continue
5760
try:
58-
mod = importlib.import_module(mod_name)
61+
mod = import_module(mod_name)
5962

6063
# Prefer module-level registry function if present
6164
if hasattr(mod, "get_available_processors"):

dlclivegui/utils/display.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class BBoxColors(enum.Enum):
1818
WHITE = (255, 255, 255)
1919
BLACK = (0, 0, 0)
2020

21+
@staticmethod
2122
def get_all_display_names() -> list[str]:
2223
return [color.name.capitalize() for color in BBoxColors]
2324

0 commit comments

Comments
 (0)