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

Open
opened 2026-05-07 00:19:28 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/271
Author: @JoseCostaUni
Created: 4/2/2026
Status: 🔄 Open

Base: mainHead: refactor/general-improvements


📝 Commits (10+)

  • 767f616 added feature.md with some possible issues/features to work on
  • 044d280 Merge branch 'IAmTomShaw:main' into main
  • de9362c fix: standardize logging framework across application
  • 16cac20 removed magic numbers and put them in a centralizec config module
  • 494f5e9 added missing file
  • f19c048 merged config refactor and loggin refactor branches
  • acf3a6f switched log library to loguru and configs to pydantic-settings
  • e937f60 added type annotations and new exceptions
  • ae38fe9 removed some more magic numbers and substituted by the respective config
  • 0889ab9 added missing configs

📊 Changes

21 files changed (+1189 additions, -367 deletions)

View changed files

📝 main.py (+20 -14)
📝 requirements.txt (+3 -1)
📝 src/bayesian_tyre_model.py (+17 -15)
📝 src/cli/race_selection.py (+2 -1)
src/config.py (+258 -0)
📝 src/f1_data.py (+137 -59)
📝 src/gui/insights_menu.py (+19 -16)
📝 src/gui/pit_wall_window.py (+5 -2)
📝 src/gui/race_selection.py (+29 -16)
📝 src/insights/telemetry_stream_viewer.py (+5 -2)
📝 src/interfaces/qualifying.py (+60 -44)
📝 src/interfaces/race_replay.py (+144 -47)
src/lib/exceptions.py (+196 -0)
src/lib/logging.py (+64 -0)
📝 src/lib/settings.py (+26 -6)
📝 src/lib/time.py (+12 -9)
📝 src/lib/tyres.py (+0 -2)
📝 src/run_session.py (+26 -9)
📝 src/services/stream.py (+51 -33)
📝 src/tyre_degradation_integration.py (+19 -14)

...and 1 more files

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/IAmTomShaw/f1-race-replay/pull/271 **Author:** [@JoseCostaUni](https://github.com/JoseCostaUni) **Created:** 4/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `refactor/general-improvements` --- ### 📝 Commits (10+) - [`767f616`](https://github.com/IAmTomShaw/f1-race-replay/commit/767f61629117264c2b7bc6a866ed56070516dd0b) added feature.md with some possible issues/features to work on - [`044d280`](https://github.com/IAmTomShaw/f1-race-replay/commit/044d280007d235e2dc10a748f920e152492142b6) Merge branch 'IAmTomShaw:main' into main - [`de9362c`](https://github.com/IAmTomShaw/f1-race-replay/commit/de9362c437f762316ad0c1bd16bd5e4ab931a4bd) fix: standardize logging framework across application - [`16cac20`](https://github.com/IAmTomShaw/f1-race-replay/commit/16cac20dce015f7302581bddfcfecb41fec210cc) removed magic numbers and put them in a centralizec config module - [`494f5e9`](https://github.com/IAmTomShaw/f1-race-replay/commit/494f5e9ca097c88c6f8e3a997202712838d0bffd) added missing file - [`f19c048`](https://github.com/IAmTomShaw/f1-race-replay/commit/f19c0489d64a49a7678a4f227a331eafcc0c1f2f) merged config refactor and loggin refactor branches - [`acf3a6f`](https://github.com/IAmTomShaw/f1-race-replay/commit/acf3a6f0e5460cbd683e7db805d50dc3f22d74dc) switched log library to loguru and configs to pydantic-settings - [`e937f60`](https://github.com/IAmTomShaw/f1-race-replay/commit/e937f607a1b8046dbf36f1494c108df1591fd80d) added type annotations and new exceptions - [`ae38fe9`](https://github.com/IAmTomShaw/f1-race-replay/commit/ae38fe93cf79599d51c3730458a3d69ed57fb421) removed some more magic numbers and substituted by the respective config - [`0889ab9`](https://github.com/IAmTomShaw/f1-race-replay/commit/0889ab98c97b1801d965c863a53c355c3c13aef2) added missing configs ### 📊 Changes **21 files changed** (+1189 additions, -367 deletions) <details> <summary>View changed files</summary> 📝 `main.py` (+20 -14) 📝 `requirements.txt` (+3 -1) 📝 `src/bayesian_tyre_model.py` (+17 -15) 📝 `src/cli/race_selection.py` (+2 -1) ➕ `src/config.py` (+258 -0) 📝 `src/f1_data.py` (+137 -59) 📝 `src/gui/insights_menu.py` (+19 -16) 📝 `src/gui/pit_wall_window.py` (+5 -2) 📝 `src/gui/race_selection.py` (+29 -16) 📝 `src/insights/telemetry_stream_viewer.py` (+5 -2) 📝 `src/interfaces/qualifying.py` (+60 -44) 📝 `src/interfaces/race_replay.py` (+144 -47) ➕ `src/lib/exceptions.py` (+196 -0) ➕ `src/lib/logging.py` (+64 -0) 📝 `src/lib/settings.py` (+26 -6) 📝 `src/lib/time.py` (+12 -9) 📝 `src/lib/tyres.py` (+0 -2) 📝 `src/run_session.py` (+26 -9) 📝 `src/services/stream.py` (+51 -33) 📝 `src/tyre_degradation_integration.py` (+19 -14) _...and 1 more files_ </details> ### 📄 Description # 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#265
No description provided.