Skip to content

Commit

Permalink
Merge pull request #32 from Packan1337/main
Browse files Browse the repository at this point in the history
added type hints to a few functions :)
  • Loading branch information
mrvladus authored Sep 1, 2023
2 parents 8e3d4cd + ed6f2ef commit 932aa7f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class Application(Adw.Application):
def __init__(self):
def __init__(self) -> None:
super().__init__(
application_id=APP_ID,
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
Expand All @@ -42,7 +42,7 @@ def do_activate(self) -> None:
# Show window
Window(application=self).present()

def load_css(self):
def load_css(self) -> None:
Log.debug("Load CSS styles")
css_provider = Gtk.CssProvider()
css_provider.load_from_resource("/io/github/mrvladus/Errands/styles.css")
Expand Down
4 changes: 2 additions & 2 deletions src/sub_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, task: dict, parent: Gtk.Box, window):
self.task_text.props.label = self.text
self.add_actions()

def add_actions(self):
def add_actions(self) -> None:
group = Gio.SimpleActionGroup.new()
self.insert_action_group("sub_task", group)

Expand Down Expand Up @@ -143,7 +143,7 @@ def on_drop(self, _drop, task, _x, _y) -> None:
break
UserData.set(data)

def check_visible():
def check_visible() -> bool:
if task.get_child_revealed():
return True
else:
Expand Down
6 changes: 3 additions & 3 deletions src/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Task(Gtk.Revealer):
# State
expanded: bool = None

def __init__(self, task: dict, window: Adw.ApplicationWindow):
def __init__(self, task: dict, window: Adw.ApplicationWindow) -> None:
super().__init__()
Log.info("Add task: " + task["text"])
self.window = window
Expand All @@ -66,7 +66,7 @@ def __init__(self, task: dict, window: Adw.ApplicationWindow):
self.task_status.add_css_class(f'progress-{self.task["color"]}')
self.add_sub_tasks()

def add_actions(self):
def add_actions(self) -> None:
group = Gio.SimpleActionGroup.new()
self.insert_action_group("task", group)

Expand Down Expand Up @@ -207,7 +207,7 @@ def toggle_tasks_data(id: str):
if task["parent"] == id:
toggle_tasks_data(task["id"])

def toggle_tasks(tasks_list: Gtk.Box):
def toggle_tasks(tasks_list: Gtk.Box) -> None:
tasks_list = tasks_list.observe_children()
for i in range(tasks_list.get_n_items()):
task = tasks_list.get_item(i)
Expand Down
6 changes: 3 additions & 3 deletions src/theme_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def __init__(self, **kwargs):
GSettings.bind("theme", self, "selected_color_scheme")

@GObject.Property(type=str)
def selected_color_scheme(self):
def selected_color_scheme(self) -> str:
return self.color_scheme

@selected_color_scheme.setter
def selected_color_scheme(self, color_scheme):
def selected_color_scheme(self, color_scheme) -> None:
self.color_scheme = color_scheme

if color_scheme == "auto":
Expand All @@ -64,7 +64,7 @@ def selected_color_scheme(self, color_scheme):
self.style_manager.props.color_scheme = Adw.ColorScheme.FORCE_DARK

@Gtk.Template.Callback()
def on_theme_change(self, _):
def on_theme_change(self, _) -> None:
if self.system.props.active:
self.selected_color_scheme = "auto"
if self.light.props.active:
Expand Down
18 changes: 9 additions & 9 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def __init__(self, **kwargs):
self.create_actions()
self.load_tasks()

def add_toast(self, toast: Adw.Toast):
def add_toast(self, toast: Adw.Toast) -> None:
self.toast_overlay.add_toast(toast)

def create_actions(self):
def create_actions(self) -> None:
"""Create actions for main menu"""

def create_action(name: str, callback: callable, shortcuts=None) -> None:
Expand Down Expand Up @@ -139,7 +139,7 @@ def finish_export(_dial, res, _data):

self.export_dialog.save(self, None, finish_export, None)

def import_tasks(self, *_):
def import_tasks(self, *_) -> None:
"""Show import dialog"""

def finish_import(_dial, res, _data):
Expand Down Expand Up @@ -269,7 +269,7 @@ def auto_scroll(scroll_up: bool) -> bool:
self.scrolling = False

@Gtk.Template.Callback()
def on_scroll(self, adj):
def on_scroll(self, adj) -> None:
"""Show scroll up button"""

self.scroll_up_btn_rev.set_reveal_child(adj.get_value() > 0)
Expand All @@ -279,7 +279,7 @@ def on_scroll(self, adj):
self.separator.remove_css_class("separator")

@Gtk.Template.Callback()
def on_scroll_up_btn_clicked(self, _):
def on_scroll_up_btn_clicked(self, _) -> None:
"""Scroll up"""

Animate.scroll(self.scrolled_window, False)
Expand Down Expand Up @@ -354,7 +354,7 @@ def on_trash_restore(self, _) -> None:
UserData.set(data)

# Restore tasks
def restore_tasks(list: Gtk.Box):
def restore_tasks(list: Gtk.Box) -> None:
"""Recursive func for restoring tasks"""

tasks = list.observe_children()
Expand Down Expand Up @@ -391,14 +391,14 @@ class TrashItem(Gtk.Box):

label = Gtk.Template.Child()

def __init__(self, task: dict, window: Window):
def __init__(self, task: dict, window: Window) -> None:
super().__init__()
self.window = window
self.id = task["id"]
self.label.props.label = task["text"]

@Gtk.Template.Callback()
def on_restore(self, _):
def on_restore(self, _) -> None:
"""Restore task"""

Log.info("Restore: " + self.label.props.label)
Expand All @@ -425,7 +425,7 @@ def restore_parent(id: str):
break

# Update UI
def restore_tasks(list: Gtk.Box):
def restore_tasks(list: Gtk.Box) -> None:
"""Recursive func for restoring tasks"""

tasks = list.observe_children()
Expand Down

0 comments on commit 932aa7f

Please sign in to comment.