Improved linting and removed unused imports

This commit is contained in:
Profitroll
2023-02-17 22:59:03 +01:00
parent 807e629ae7
commit b766d0c52c
8 changed files with 31 additions and 157 deletions

View File

@@ -9,10 +9,11 @@ from sys import exit
from os import sep, kill
from os import name as osname
from traceback import print_exc
from typing import Any
from modules.logger import logWrite
def jsonLoad(filename):
def jsonLoad(filename: str) -> Any:
"""Loads arg1 as json and returns its contents"""
with open(filename, "r", encoding='utf8') as file:
try:
@@ -26,7 +27,7 @@ def jsonLoad(filename):
file.close()
return output
def jsonSave(contents, filename):
def jsonSave(contents: Any, filename: str) -> None:
"""Dumps dict/list arg1 to file arg2"""
try:
with open(filename, "w", encoding='utf8') as file:
@@ -108,10 +109,14 @@ except ModuleNotFoundError:
print(locale("deps_missing", "console", locale=configGet("locale")), flush=True)
exit()
def killProc(pid):
def killProc(pid: int) -> None:
"""Kill process by its PID. Meant to be used to kill the main process of bot itself.
### Args:
* pid (`int`): PID of the target
"""
if osname == "posix":
from signal import SIGKILL
kill(pid, SIGKILL)
else:
p = Process(pid)
p.kill()
Process(pid).kill()