Skip to content

[Refactor] Centralized configs, standardizes logging with loguru and add type safety#271

Open
JoseCostaUni wants to merge 17 commits into
IAmTomShaw:mainfrom
JoseCostaUni:refactor/general-improvements
Open

[Refactor] Centralized configs, standardizes logging with loguru and add type safety#271
JoseCostaUni wants to merge 17 commits into
IAmTomShaw:mainfrom
JoseCostaUni:refactor/general-improvements

Conversation

@JoseCostaUni

Copy link
Copy Markdown

Summary

  • Introduces src/config.py — a single source of truth for all configuration using pydantic-settings. All magic numbers (screen size, FPS, network ports, playback speeds, UI margins, etc.) are now named, documented, and overridable via environment variables or .env.
  • Switches the logging stack to loguru with a unified {timestamp} | {level} | {module} | {message} format.
  • Adds src/lib/exceptions.py with a structured exception hierarchy (F1DataError, StreamError, SessionNotAvailableError, etc.) replacing bare raise Exception(...) calls.
  • Adds return type annotations and parameter types across stream.py, qualifying.py, f1_data.py, and others.

Closes issue #270

JoseCostaUni and others added 17 commits March 11, 2026 22:51
- Add centralized logging configuration in src/lib/logging.py
- Replace 50+ print statements with appropriate logger levels
- Support --debug flag for verbose output
- Add logger imports to all affected modules:
  * main.py
  * src/f1_data.py
  * src/interfaces/qualifying.py
  * src/services/stream.py
  * src/ui_components.py
  * src/run_session.py
  * src/gui/pit_wall_window.py
  * src/gui/insights_menu.py
  * src/insights/telemetry_stream_viewer.py

Fixes IAmTomShaw#39, enables better debugging of IAmTomShaw#245 and IAmTomShaw#127
Improves visibility of errors and processing steps
…ntime

popup_width, popup_height, popup_header_font_size, popup_body_font_size,
and map_padding_ratio_default were referenced in race_replay.py but were
never added to UIConfig after the magic-number removal commit (0889ab9).
…alues

- Updated safety_car_glow_alpha default from 128 to 80 in UIConfig
- Replaced hardcoded regular_car_radius (6) with UIConfig.regular_car_radius
- Replaced hardcoded safety_car_glow_alpha (80) with UIConfig.safety_car_glow_alpha
- Replaced hardcoded safety_car_radius (8) with UIConfig.safety_car_radius

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant