Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor initialization, functions and classes #1388

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

C0rn3j
Copy link
Collaborator

@C0rn3j C0rn3j commented Jan 12, 2025

image

This is effectively a complete refactor of Tauon's Python side.

This introduces a new dataclass called Bag in t_main.py, created after Prefs (technically it could be merged into Prefs, but that is big enough and it's not a Preference but mostly an object holder), which partially absorbs the initial Holder from __main__.py, and later the Tauon class absorbs Bag and Holder.

Things were rearranged to allow this hierarchy, most classes are now initialized within Tauon or PlayerCtl, as needed.

This allows us to pass Holder, Bag and later Tauon everywhere, allowing access to all the things that used to be either explicit or implicit globals, all the while allowing type checkers to understand the code and not crash/timeout as is the current case with master.

Launches, but has a couple issues I've managed to introduce (likely when removing the globals), the code is a little ugly at the moment in parts, and it is far from done, albeit mergeable if it weren't for the new issues.

I've been chopping this PR up into pieces and sending the working bits to master in a reviewable fashion for now, as it touches 37K lines at the time of writing, out of the total 47K~.


Biggest problems with this WIP branch are:

  • Lack of input - can't even press X to exit
  • The player freezing on hover when a track is playing (but radio works)
  • Player sending hundreds of notifications a second by constantly calling threading.Thread(target=self.notify_song_fire, args=([self.song_notification, delay, id]))
  • Some imports not working due to being imported in main() and not passed in any way
  • Some random issues marked with a TODO(Martin)

The goals here are:

  • Stop using class globals - LoadImageAsset, WhiteModImageAsset, TextBox and TextBox2 are left
  • Rework functions and classes to be initialized without implicitly relying on globals
  • Remove all explicit globals
  • Convert Prefs to dataclass
  • Get rid of t_bootstrap.py by turning its contents into a regular class object, currently it functions as a global object import of sorts. Instead we'll create a main() function in t_main.py to be able to pass it, to do so we'll have to get rid of doing everything in the top level of the module

2025-03-03 - 4352 Ruff issues, 27804 Pyright issues in master

2025-03-02 - 3968 Ruff issues, 14947 Pyright issues in PR
2025-03-03 - 2946 Ruff issues, 14261 Pyright issues in PR (1K Ruff issues are line-too-long which are hidden for now)
2025-03-04 - 2544 Ruff issues, 14468 Pyright issues in PR

@C0rn3j C0rn3j force-pushed the 800 branch 5 times, most recently from f7da9a9 to 455399d Compare February 8, 2025 15:03
@C0rn3j C0rn3j changed the title Refactor initialization and classes Refactor initialization, functions and classes Feb 8, 2025
@C0rn3j C0rn3j force-pushed the 800 branch 2 times, most recently from 6d4f331 to 7e12556 Compare February 16, 2025 16:32
@C0rn3j C0rn3j force-pushed the 800 branch 4 times, most recently from 226f583 to 6015c4a Compare February 16, 2025 19:45
@C0rn3j C0rn3j closed this Feb 17, 2025
@C0rn3j C0rn3j reopened this Feb 17, 2025
C0rn3j added a commit to C0rn3j/Tauon that referenced this pull request Feb 26, 2025
C0rn3j added a commit to C0rn3j/Tauon that referenced this pull request Feb 28, 2025
C0rn3j added a commit to C0rn3j/Tauon that referenced this pull request Feb 28, 2025
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