]> git.scottworley.com Git - nix-env-apps/blobdiff - apps.py
mypy, pylint, autopep8, & pre-commit hook to run them
[nix-env-apps] / apps.py
diff --git a/apps.py b/apps.py
index 4b0d0d581a5c917d442baf3f64432c9b1b37c36c..959c14893af48934260d651d2851b96c29083bdf 100644 (file)
--- a/apps.py
+++ b/apps.py
@@ -1,12 +1,13 @@
-from gi.repository import Gtk
 import os
 import subprocess
 import os
 import subprocess
+from typing import Any
 
 import gi
 gi.require_version("Gtk", "4.0")
 
 import gi
 gi.require_version("Gtk", "4.0")
+from gi.repository import Gtk  # nopep8 pylint: disable=wrong-import-position
 
 
 
 
-def on_edit(_):
+def on_edit(_: Any) -> None:
     config_dir = os.path.join(
         os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config')),
         'nixpkgs',
     config_dir = os.path.join(
         os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config')),
         'nixpkgs',
@@ -14,7 +15,7 @@ def on_edit(_):
     os.makedirs(config_dir, exist_ok=True)
     config_file = os.path.join(config_dir, 'userPackages.nix')
     try:
     os.makedirs(config_dir, exist_ok=True)
     config_file = os.path.join(config_dir, 'userPackages.nix')
     try:
-        with open(config_file, mode="x") as f:
+        with open(config_file, mode="x", encoding='utf-8') as f:
             f.write('''final: prev: {
   userPackages = final.buildEnv {
     name = "userPackages";
             f.write('''final: prev: {
   userPackages = final.buildEnv {
     name = "userPackages";
@@ -31,17 +32,19 @@ def on_edit(_):
     subprocess.run(['xdg-open', config_file], check=True)
 
 
     subprocess.run(['xdg-open', config_file], check=True)
 
 
-def try_exec_terminal(terminal, args):
+def try_exec_terminal(terminal: str, args: list[str]) -> None:
     try:
         os.execvp(terminal, [terminal] + args)
     except FileNotFoundError:
         pass
 
 
     try:
         os.execvp(terminal, [terminal] + args)
     except FileNotFoundError:
         pass
 
 
-def on_apply(_):
+def on_apply(_: Any) -> None:
     command = ['nix-env', '-riA', 'nixos.userPackages']
     command_string = ' '.join(command)
     command = ['nix-env', '-riA', 'nixos.userPackages']
     command_string = ' '.join(command)
-    close_string = ''' && read -p "SUCCESS: Press ENTER to close this window" || read -p "FAILURE: Press ENTER to close this window"'''
+    close_string = (
+        ''' && read -p "SUCCESS: Press ENTER to close this window"''' +
+        ''' || read -p "FAILURE: Press ENTER to close this window"''')
     # This should be a simple `xdg-terminal` invocation, but as of 2025,
     # xdg-terminal is extremely broken in Gnome:
     #   * It doesn't cause a terminal window to appear
     # This should be a simple `xdg-terminal` invocation, but as of 2025,
     # xdg-terminal is extremely broken in Gnome:
     #   * It doesn't cause a terminal window to appear
@@ -77,7 +80,7 @@ def on_apply(_):
         os.execvp(command[0], command)
 
 
         os.execvp(command[0], command)
 
 
-def on_activate(app):
+def on_activate(app: Gtk.Application) -> None:
     win = Gtk.ApplicationWindow(application=app)
     box = Gtk.Box()
     box.set_orientation(Gtk.Orientation.VERTICAL)
     win = Gtk.ApplicationWindow(application=app)
     box = Gtk.Box()
     box.set_orientation(Gtk.Orientation.VERTICAL)
@@ -91,7 +94,7 @@ def on_activate(app):
     win.present()
 
 
     win.present()
 
 
-def main():
+def main() -> None:
     app = Gtk.Application(application_id='net.chkno.nix-env-apps')
     app.connect('activate', on_activate)
     app.run(None)
     app = Gtk.Application(application_id='net.chkno.nix-env-apps')
     app.connect('activate', on_activate)
     app.run(None)