Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
[code] Update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Dec 15, 2020
1 parent 1de965d commit a84f32f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions mp3monitoring/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __run(self):
return

@property
def status(self):
def status(self) -> str:
return self._status

@status.setter
Expand Down Expand Up @@ -156,10 +156,10 @@ def join(self):
def is_stopping(self):
return self._sleep_event.is_set()

def is_active(self):
def is_active(self) -> bool:
return self._active

def tooltip(self):
def tooltip(self) -> str:
if self.status == 'error':
return "error: " + self._err_msg
return self.status
6 changes: 3 additions & 3 deletions mp3monitoring/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def __init__(self):
self.start_with_system: bool = False

@classmethod
def from_dict(cls, file: Path, j_dict: dict):
def from_dict(cls, file: Path, j_dict: dict) -> 'Settings':
settings = cls()
settings.file = file
settings.start_minimized = j_dict.get('start_minimized', settings.start_minimized)
settings.start_with_system = j_dict.get('start_with_system', settings.start_with_system)
return settings

def to_dict(self):
def to_dict(self) -> dict:
return {
'start_minimized': self.start_minimized,
'start_with_system': self.start_with_system,
Expand All @@ -43,7 +43,7 @@ def load_old_config(file: Path) -> List[JobConfig]:
return jobs


def load_config(file: Path = Path.home().joinpath(".mp3monitoring/config.json")) -> (Settings, List[JobConfig]):
def load_config(file: Path = Path.home().joinpath(".mp3monitoring/config.json")) -> tuple[Settings, List[JobConfig]]:
load_old_config(file.parent.joinpath('data.sav'))

if not file.exists():
Expand Down
1 change: 1 addition & 0 deletions mp3monitoring/gui/dialog/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def update_app_check(self):
if not self._update_app_runner.succeed:
show.information_dialog("Failed to update", self._update_app_runner.err_msg)
return
self.update_now.hide()
self.update_info.setText("Restart to finish the update.")
show.information_dialog("Update succeed", "Restart the app to finish the update.")

Expand Down
2 changes: 1 addition & 1 deletion mp3monitoring/gui/dialog/add_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def target_dir_dialog(self):
selected_dir = QFileDialog.getExistingDirectory(self.parent(), 'Select a target directory', options=QFileDialog.ShowDirsOnly)
self.target_dir.setText(selected_dir)

def get_config(self):
def get_config(self) -> tuple[JobConfig, bool]:
return JobConfig(Path(self.source_dir.text()), Path(self.target_dir.text()), self.run_at_startup.isChecked(),
QTime(0, 0, 0).secsTo(self.sleep_time.time()), self.recursive_search.isChecked()), self.start_job

Expand Down
9 changes: 6 additions & 3 deletions mp3monitoring/gui/dialog/show.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from PySide2.QtCore import Qt
from PySide2.QtGui import QIcon
from PySide2.QtWidgets import QMessageBox
from mp3monitoring.core.manager import Manager

from mp3monitoring.core.settings import Settings

from mp3monitoring.gui import pkg_data
from mp3monitoring.gui.dialog.about import AboutDialog
Expand All @@ -13,14 +16,14 @@ def about_dialog(parent=None):
dialog.open()


def settings_dialog(settings, manager, parent=None):
def settings_dialog(settings: Settings, manager: Manager, parent=None):
dialog = SettingsDialog(settings, manager, parent)
dialog.setWindowIcon(QIcon(str(pkg_data.SETTINGS_SYMBOL)))
dialog.setAttribute(Qt.WA_DeleteOnClose, True)
dialog.open()


def question_dialog(win_title, msg):
def question_dialog(win_title: str, msg: str):
msg_box = QMessageBox()
msg_box.setIcon(QMessageBox.Question)
msg_box.setWindowIcon(QIcon(str(pkg_data.LOGO)))
Expand All @@ -32,7 +35,7 @@ def question_dialog(win_title, msg):
return reply


def information_dialog(win_title, msg):
def information_dialog(win_title: str, msg: str):
msg_box = QMessageBox()
msg_box.setIcon(QMessageBox.Information)
msg_box.setWindowIcon(QIcon(str(pkg_data.LOGO)))
Expand Down
2 changes: 1 addition & 1 deletion mp3monitoring/gui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_for_app_updates() -> bool:
return get_newest_app_version() > Version(static_data.VERSION)


def update() -> (bool, str):
def update() -> tuple[bool, str]:
try:
subprocess.run([sys.executable, '-m', 'pip', 'install', '--upgrade', 'mp3monitoring'], stdout=sys.stdout, stderr=sys.stderr, check=True)
except subprocess.CalledProcessError as ex:
Expand Down
2 changes: 1 addition & 1 deletion mp3monitoring/gui/window/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def changeEvent(self, event):
if QSystemTrayIcon.supportsMessages():
self.tray_icon.showMessage("MP3 Monitoring is running in background!", "Double click the tray icon to open and right click for menu.")

def closeEvent(self, event: QCloseEvent, close_immediately=False):
def closeEvent(self, event: QCloseEvent):
event.ignore()
self.exit()

Expand Down
2 changes: 1 addition & 1 deletion mp3monitoring/static_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#: long name of this program
LONG_NAME = "MP3 Monitoring"
#: version in PEP440 format
VERSION = '2.0.0.dev5'
VERSION = '1.0.0.dev5'
#: url to the pypi json
PYPI_JSON_URL = 'https://pypi.org/pypi/mp3monitoring/json'
#: author
Expand Down
6 changes: 3 additions & 3 deletions mp3monitoring/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mp3monitoring.gui import pkg_data


def is_mp3(file_path: Path):
def is_mp3(file_path: Path) -> bool:
"""
Return true if a file is an mp3.
:param file_path: file to be checked
Expand All @@ -21,7 +21,7 @@ def is_mp3(file_path: Path):
return False


def create_start_menu_entry():
def create_start_menu_entry() -> tuple[bool, str]:
start_menu_dir = Path.home() / "AppData" / "Roaming" / "Microsoft" / "Windows" / "Start Menu" / "Programs"
start_menu_entry = start_menu_dir / "MP3 Monitoring.lnk"

Expand All @@ -36,7 +36,7 @@ def create_start_menu_entry():
return True, ""


def edit_startup_link(create: bool = True) -> (bool, str):
def edit_startup_link(create: bool = True) -> tuple[bool, str]:
"""
:param create: Create or remove the link.
Expand Down

0 comments on commit a84f32f

Please sign in to comment.