feat(types): Complete strict static analysis and typing track

This commit is contained in:
2026-03-04 09:46:02 -05:00
parent c6c2a1b40c
commit fe2114a2e0
46 changed files with 606 additions and 795 deletions

View File

@@ -22,13 +22,14 @@ Usage
import dearpygui.dearpygui as dpg
from pathlib import Path
from typing import Any
# ------------------------------------------------------------------ palettes
# Colour key names match the DPG mvThemeCol_* constants (string lookup below).
# Only keys that differ from DPG defaults need to be listed.
_PALETTES: dict[str, dict] = {
_PALETTES: dict[str, dict[str, Any]] = {
"DPG Default": {}, # empty = reset to DPG built-in defaults
"10x Dark": {
# Window / frame chrome
@@ -285,11 +286,11 @@ def get_current_font_size() -> float:
def get_current_scale() -> float:
return _current_scale
def get_palette_colours(name: str) -> dict:
def get_palette_colours(name: str) -> dict[str, Any]:
"""Return a copy of the colour dict for the named palette."""
return dict(_PALETTES.get(name, {}))
def apply(palette_name: str, overrides: dict | None = None) -> None:
def apply(palette_name: str, overrides: dict[str, Any] | None = None) -> None:
"""
Build a global DPG theme from the named palette plus optional per-colour
overrides, and bind it as the default theme.
@@ -368,7 +369,7 @@ def set_scale(factor: float) -> None:
_current_scale = factor
dpg.set_global_font_scale(factor)
def save_to_config(config: dict) -> None:
def save_to_config(config: dict[str, Any]) -> None:
"""Persist theme settings into the config dict under [theme]."""
config.setdefault("theme", {})
config["theme"]["palette"] = _current_palette
@@ -376,7 +377,7 @@ def save_to_config(config: dict) -> None:
config["theme"]["font_size"] = _current_font_size
config["theme"]["scale"] = _current_scale
def load_from_config(config: dict) -> None:
def load_from_config(config: dict[str, Any]) -> None:
"""Read [theme] from config and apply everything."""
t = config.get("theme", {})
palette = t.get("palette", "DPG Default")