diff --git a/slpkg/checks.py b/slpkg/checks.py index 992e0ada..6cd924cb 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from pathlib import Path +from typing import NoReturn from slpkg.configs import Configs from slpkg.queries import SBoQueries @@ -17,7 +18,7 @@ class Check(Configs, Utilities): super(Utilities, self).__init__() @staticmethod - def exists(slackbuilds: list) -> None: + def exists(slackbuilds: list) -> NoReturn: """ Checking if the slackbuild exists in the repository. """ not_packages: list = [] @@ -30,7 +31,7 @@ class Check(Configs, Utilities): 'does not exists.\n') @staticmethod - def unsupported(slackbuilds: list) -> None: + def unsupported(slackbuilds: list) -> NoReturn: """ Checking for unsupported slackbuilds. """ for sbo in slackbuilds: sources = SBoQueries(sbo).sources() @@ -56,7 +57,7 @@ class Check(Configs, Utilities): return found - def blacklist(self, slackbuilds: list) -> None: + def blacklist(self, slackbuilds: list) -> NoReturn: """ Checking if the packages are blacklisted. """ packages: list = [] black = Blacklist() @@ -71,7 +72,7 @@ class Check(Configs, Utilities): f'Please edit the blacklist.toml file in ' f'{self.configs.etc_path} folder.\n') - def database(self) -> None: + def database(self) -> NoReturn: """ Checking for empty table """ db = Path(self.db_path, self.database_name) if not SBoQueries('').sbos() or not db.is_file(): diff --git a/slpkg/dependees.py b/slpkg/dependees.py index f333568b..443df06c 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +from typing import Generator from slpkg.configs import Configs from slpkg.views.ascii import Ascii from slpkg.queries import SBoQueries @@ -46,7 +47,7 @@ class Dependees(Configs, Utilities): package: str = f'{self.byellow}{pkg}{self.endc}' if self.is_option(self.flag_pkg_version, self.flags): - package = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}' + package: str = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}' print(package) @@ -76,7 +77,7 @@ class Dependees(Configs, Utilities): print(f'\n{self.grey}{len(dependees)} dependees for {pkg}{self.endc}\n') - def find_requires(self, sbo): + def find_requires(self, sbo: str) -> Generator[str]: """ Find requires that slackbuild dependees. """ requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() for req in requires: diff --git a/slpkg/downloader.py b/slpkg/downloader.py index 7b69c1c3..fe0ae555 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -4,8 +4,8 @@ import os import subprocess from pathlib import Path -from typing import Union from urllib.parse import unquote +from typing import Union, NoReturn from multiprocessing import Process from slpkg.configs import Configs @@ -41,7 +41,7 @@ class Downloader(Configs, Utilities): self.bred: str = f'{self.bold}{self.red}' self.flag_no_silent: list = ['-n', '--no-silent'] - def transfer_tools(self) -> None: + def transfer_tools(self) -> NoReturn: """ Wget downloader. """ if self.downloader == 'wget': self.output = subprocess.call(f'{self.downloader} {self.wget_options} --directory-prefix={self.path} ' @@ -57,7 +57,7 @@ class Downloader(Configs, Utilities): if self.output != 0: raise SystemExit(self.output) - def lftp(self) -> None: + def lftp(self) -> NoReturn: """ Downloads scripts from ponce repository. PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/ @@ -74,7 +74,7 @@ class Downloader(Configs, Utilities): if self.output != 0: raise SystemExit(self.output) - def check_if_downloaded(self) -> None: + def check_if_downloaded(self) -> NoReturn: """ Checks if the file downloaded. """ if not self.ponce_repo and 'ponce' not in self.url: url: str = unquote(self.url) diff --git a/slpkg/main.py b/slpkg/main.py index bdaaf67b..bc4b442d 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -3,6 +3,7 @@ import os import sys +from typing import NoReturn from slpkg.checks import Check from slpkg.upgrade import Upgrade @@ -281,7 +282,7 @@ class Argparse(Configs): self.args.remove(opt) self.flags.append(opt) - def is_dialog_enabled(self) -> None: + def is_dialog_enabled(self) -> NoReturn: """ Checking if the dialog box is enabled. """ if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or not self.dialogbox.dialog and 'configs' in self.args): @@ -365,21 +366,21 @@ class Argparse(Configs): self.usage.help(0) self.usage.help(1) - def version(self) -> None: + def version(self) -> NoReturn: if len(self.args) == 1: version = Version() version.view() raise SystemExit() self.usage.help(1) - def update(self) -> None: + def update(self) -> NoReturn: if len(self.args) == 1: update = UpdateRepository(self.flags) update.repository() raise SystemExit() self.usage.help(1) - def upgrade(self) -> None: + def upgrade(self) -> NoReturn: command = Argparse.upgrade.__name__ if len(self.args) == 1: @@ -399,7 +400,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def check_updates(self) -> None: + def check_updates(self) -> NoReturn: if len(self.args) == 1: self.check.database() @@ -408,13 +409,13 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def edit_configs(self) -> None: + def edit_configs(self) -> NoReturn: if len(self.args) == 1: self.form_configs.edit() raise SystemExit() self.usage.help(1) - def clean_logs(self) -> None: + def clean_logs(self) -> NoReturn: if len(self.args) == 1: self.check.database() @@ -423,7 +424,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def clean_tmp(self) -> None: + def clean_tmp(self) -> NoReturn: if len(self.args) == 1: self.utils.remove_folder_if_exists(path=self.tmp_path, folder=self.prog_name) @@ -433,7 +434,7 @@ class Argparse(Configs): self.usage.help(1) - def build(self) -> None: + def build(self) -> NoReturn: command = Argparse.build.__name__ if len(self.args) >= 2: @@ -451,7 +452,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def install(self) -> None: + def install(self) -> NoReturn: command = Argparse.install.__name__ if len(self.args) >= 2: @@ -469,7 +470,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def download(self) -> None: + def download(self) -> NoReturn: command = Argparse.download.__name__ if len(self.args) >= 2: @@ -485,7 +486,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def remove(self) -> None: + def remove(self) -> NoReturn: command = Argparse.remove.__name__ if len(self.args) >= 2: @@ -502,7 +503,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def find(self) -> None: + def find(self) -> NoReturn: command = Argparse.find.__name__ if len(self.args) >= 2: @@ -518,7 +519,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def view(self) -> None: + def view(self) -> NoReturn: command = Argparse.view.__name__ if len(self.args) >= 2: @@ -535,7 +536,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def search(self) -> None: + def search(self) -> NoReturn: command = Argparse.search.__name__ if len(self.args) >= 2: @@ -551,7 +552,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def dependees(self) -> None: + def dependees(self) -> NoReturn: command = Argparse.dependees.__name__ if len(self.args) >= 2: @@ -568,7 +569,7 @@ class Argparse(Configs): raise SystemExit() self.usage.help(1) - def tracking(self) -> None: + def tracking(self) -> NoReturn: command = Argparse.tracking.__name__ if len(self.args) >= 2: diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index a915a090..f6449eed 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -3,6 +3,7 @@ import time import subprocess +from typing import NoReturn from multiprocessing import Process from slpkg.configs import Configs @@ -123,14 +124,14 @@ class RemovePackages(Configs): self.print_error() - def process(self, command: str) -> None: + def process(self, command: str) -> NoReturn: """ Processes execution. """ self.output = subprocess.call(command, shell=True, stderr=self.stderr, stdout=self.stdout) if self.output != 0: raise SystemExit(self.output) - def print_error(self) -> None: + def print_error(self) -> NoReturn: """ Stop the process and print the error message. """ if self.output != 0: raise SystemExit(f"\n{self.red}FAILED {self.stderr}:{self.endc} package '{self.remove_pkg}' to remove.\n") diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index d9848f6b..7fced330 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -4,6 +4,7 @@ import os import time import subprocess +from typing import NoReturn from pathlib import Path from collections import OrderedDict @@ -316,14 +317,14 @@ class Slackbuilds(Configs): self.print_error() - def process(self, command: str) -> None: + def process(self, command: str) -> NoReturn: """ Processes execution. """ self.output = subprocess.call(command, shell=True, stderr=self.stderr, stdout=self.stdout) if self.output != 0: raise SystemExit(self.output) - def print_error(self) -> None: + def print_error(self) -> NoReturn: """ Stop the process and print the error message. """ if self.output != 0: raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} {self.process_message}.\n") diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index bdb73530..2b3014b6 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +from typing import NoReturn from slpkg.configs import Configs @@ -16,7 +17,7 @@ class Usage(Configs): self.yellow: str = color['yellow'] self.endc: str = color['endc'] - def help_short(self) -> None: + def help_short(self) -> NoReturn: """ Prints the short menu. """ args = ( f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n' @@ -34,7 +35,7 @@ class Usage(Configs): print(args) raise SystemExit() - def help(self, status: int) -> None: + def help(self, status: int) -> NoReturn: """ Prints the main menu. """ args: str = ( f'{self.bold}USAGE:{self.endc} {self.prog_name} [{self.yellow}OPTIONS{self.endc}] ' @@ -77,7 +78,7 @@ class Usage(Configs): print(args) raise SystemExit(status) - def error_for_options(self, command: str, flags: list) -> None: + def error_for_options(self, command: str, flags: list) -> NoReturn: """ Error messages for flags. """ flags.reverse() # Put first the short options. print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] ' diff --git a/slpkg/views/views.py b/slpkg/views/views.py index a7f5608a..c9042fbc 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import os -from typing import Any +from typing import Any, NoReturn from slpkg.configs import Configs from slpkg.views.ascii import Ascii @@ -229,7 +229,7 @@ class ViewMessage(Configs): print('Note: After cleaning you should remove them one by one.') - def question(self) -> None: + def question(self) -> NoReturn: """ Manage to proceed. """ if not self.utils.is_option(self.flag_yes, self.flags): answer: str = input('\nDo you want to continue? [y/N] ')