Skip to content

Commit 8916de1

Browse files
committed
correct type annotation
1 parent e8bdbc1 commit 8916de1

File tree

7 files changed

+33
-177
lines changed

7 files changed

+33
-177
lines changed

app/__main__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
from qasync import QApplication, run
77

88
from app.builtin.gitlab_updater import GitlabUpdater
9-
from app.builtin.theme_manager import ThemeManager, enable_hi_dpi
109
from app.main_window import MainWindow
10+
from qdarktheme import enable_hi_dpi
1111

1212

1313
async def task():
1414
app_close_event = asyncio.Event()
1515
app = QApplication.instance()
16+
assert(app is QApplication)
1617
app.aboutToQuit.connect(app_close_event.set)
1718

1819
main_window = MainWindow()
@@ -51,18 +52,13 @@ def main(enable_updater: bool = True):
5152
translator.load(f":/i18n/{lang_code}.qm")
5253
app.installTranslator(translator)
5354

54-
# theme
55-
theme = ThemeManager()
56-
5755
# start event loop
5856
run(task())
5957

6058

6159
def main_no_updater():
62-
main(
63-
enable_updater=False
64-
)
60+
main(enable_updater=False)
6561

6662

67-
if __name__ == '__main__':
63+
if __name__ == "__main__":
6864
main()

app/builtin/async_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def closeEvent(self, event):
1515
self._closed.emit()
1616
super().closeEvent(event)
1717

18-
async def show(self):
18+
async def async_show(self):
1919
future = asyncio.get_event_loop().create_future()
2020

2121
def resolve_future():

app/builtin/theme_manager.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

app/builtin/update.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,32 @@ class Updater(ABC):
5454
_updated_cmd = "--updater-updated"
5555
_disable_cmd = "--updater-disable"
5656

57-
_instance = None
58-
59-
def __new__(cls):
60-
if cls._instance is None:
61-
cls._instance = super().__new__(cls)
62-
cls._instance._initialized = False
63-
return cls._instance
57+
current_version :Version
6458

6559
def __init__(self):
66-
if not self._initialized:
67-
# Three attributes can be set by updater.json
68-
self.current_version = Updater._load_current_version()
69-
self.release_type = self.current_version.release_type
70-
self.proxy = None
71-
72-
# must set in self.fetch()
73-
self.remote_version = None
74-
self.description = ""
75-
self.download_url = ""
76-
self.filename = ""
77-
78-
self.is_updated = False
79-
self.is_enable = True
80-
if Updater._copy_self_cmd in sys.argv:
81-
sys.argv.remove(Updater._copy_self_cmd)
82-
Updater.copy_self_and_exit()
83-
if Updater._updated_cmd in sys.argv:
84-
sys.argv.remove(Updater._updated_cmd)
85-
self.is_updated = True
86-
Updater.clean_old_package()
87-
if Updater._disable_cmd in sys.argv:
88-
sys.argv.remove(Updater._disable_cmd)
89-
self.is_enable = False
60+
# Three attributes can be set by updater.json
61+
self.current_version = Updater._load_current_version()
62+
self.release_type = self.current_version.release_type
63+
self.proxy = None
64+
65+
# must set in self.fetch()
66+
self.remote_version = None
67+
self.description = ""
68+
self.download_url = ""
69+
self.filename = ""
70+
71+
self.is_updated = False
72+
self.is_enable = True
73+
if Updater._copy_self_cmd in sys.argv:
74+
sys.argv.remove(Updater._copy_self_cmd)
75+
Updater.copy_self_and_exit()
76+
if Updater._updated_cmd in sys.argv:
77+
sys.argv.remove(Updater._updated_cmd)
78+
self.is_updated = True
79+
Updater.clean_old_package()
80+
if Updater._disable_cmd in sys.argv:
81+
sys.argv.remove(Updater._disable_cmd)
82+
self.is_enable = False
9083

9184
self._initialized = True
9285

@@ -115,6 +108,7 @@ def _load_current_version():
115108
return Version(__version__)
116109

117110
def check_for_update(self):
111+
assert(self.remote_version is Version)
118112
return (self.release_type == self.remote_version.release_type
119113
and self.remote_version > self.current_version)
120114

app/main_window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from qasync import asyncSlot
88

99
import app.resources.resource # type: ignore
10-
from app.builtin.theme_manager import ThemeManager
1110
from app.builtin.update_widget import UpdateWidget
1211
from app.resources.main_window_ui import Ui_MainWindow
12+
from qdarktheme import setup_theme
1313

1414

1515
class MainWindow(QMainWindow):
@@ -50,7 +50,7 @@ async def check_update(self, updater):
5050
await updater.fetch()
5151
if updater.check_for_update():
5252
update_widget = UpdateWidget(self, updater)
53-
await update_widget.show()
53+
await update_widget.async_show()
5454
if update_widget.need_restart:
5555
updater.apply_update()
5656
self.close()
@@ -91,4 +91,4 @@ async def async_task():
9191

9292
def change_theme(self, index):
9393
theme = self.ui.themeComboBox.itemData(index)
94-
ThemeManager().setup_theme(theme)
94+
setup_theme(theme)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies = [
99
"packaging>=25.0",
1010
"qasync>=0.28.0",
1111
"glom>=24.11.0",
12-
"pyqtdarktheme>=0.1.6",
1312
"pyside6>=6.1.3",
1413
"singleton-decorator>=1.0.0",
1514
]

uv.lock

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)