From 54a331cc9666d2649826d3dfb8b8e528e4eddde6 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Mon, 26 Aug 2024 23:32:02 +0300 Subject: [PATCH] docs: update booleans in docs --- src/ahriman/application/handlers/handler.py | 4 ++-- src/ahriman/application/lock.py | 6 +++--- src/ahriman/core/alpm/pacman_database.py | 2 +- src/ahriman/core/auth/auth.py | 6 +++--- src/ahriman/core/auth/helpers.py | 8 ++++---- src/ahriman/core/auth/mapping.py | 8 ++++---- src/ahriman/core/auth/pam.py | 6 +++--- src/ahriman/core/build_tools/sources.py | 6 +++--- src/ahriman/core/configuration/validator.py | 2 +- src/ahriman/core/database/operations/operations.py | 2 +- src/ahriman/core/formatters/build_printer.py | 4 ++-- src/ahriman/core/formatters/changes_printer.py | 2 +- src/ahriman/core/formatters/printer.py | 2 +- src/ahriman/core/formatters/string_printer.py | 2 +- src/ahriman/core/http/sync_http_client.py | 2 +- src/ahriman/core/report/jinja_template.py | 4 ++-- src/ahriman/core/report/remote_call.py | 2 +- src/ahriman/core/spawn.py | 4 ++-- src/ahriman/core/status/client.py | 4 ++-- src/ahriman/core/status/local_client.py | 4 ++-- src/ahriman/core/status/web_client.py | 4 ++-- src/ahriman/core/tree.py | 4 ++-- src/ahriman/core/upload/github.py | 2 +- src/ahriman/core/utils.py | 6 +++--- src/ahriman/models/auth_settings.py | 2 +- src/ahriman/models/event.py | 7 +++++-- src/ahriman/models/migration_result.py | 2 +- src/ahriman/models/package.py | 6 +++--- src/ahriman/models/pkgbuild_patch.py | 4 ++-- src/ahriman/models/property.py | 2 +- src/ahriman/models/remote_source.py | 2 +- src/ahriman/models/repository_id.py | 4 ++-- src/ahriman/models/result.py | 4 ++-- src/ahriman/models/user.py | 4 ++-- src/ahriman/models/user_access.py | 2 +- src/ahriman/web/middlewares/auth_handler.py | 4 ++-- src/ahriman/web/middlewares/exception_handler.py | 2 +- src/ahriman/web/views/base.py | 2 +- tests/ahriman/models/test_event.py | 4 ++-- 39 files changed, 75 insertions(+), 72 deletions(-) diff --git a/src/ahriman/application/handlers/handler.py b/src/ahriman/application/handlers/handler.py index 2120ff4e..f6e10fb8 100644 --- a/src/ahriman/application/handlers/handler.py +++ b/src/ahriman/application/handlers/handler.py @@ -59,7 +59,7 @@ class Handler: repository_id(RepositoryId): repository unique identifier Returns: - bool: True on success, False otherwise + bool: ``True`` on success, ``False`` otherwise """ try: configuration = Configuration.from_path(args.configuration, repository_id) @@ -129,7 +129,7 @@ class Handler: check condition and flag and raise ExitCode exception in case if it is enabled and condition match Args: - enabled(bool): if False no check will be performed + enabled(bool): if ``False`` no check will be performed predicate(bool): indicates condition on which exception should be thrown Raises: diff --git a/src/ahriman/application/lock.py b/src/ahriman/application/lock.py index 56aab2d9..d4b5fe39 100644 --- a/src/ahriman/application/lock.py +++ b/src/ahriman/application/lock.py @@ -97,7 +97,7 @@ class Lock(LazyLogging): fd(int): file descriptor: Returns: - bool: True in case if file is locked and False otherwise + bool: ``True`` in case if file is locked and ``False`` otherwise """ try: fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) @@ -119,7 +119,7 @@ class Lock(LazyLogging): watch until lock disappear Returns: - bool: True in case if file is locked and False otherwise + bool: ``True`` in case if file is locked and ``False`` otherwise """ # there are reasons why we are not using inotify here. First of all, if we would use it, it would bring to # race conditions because multiple processes will be notified at the same time. Secondly, it is good library, @@ -223,7 +223,7 @@ class Lock(LazyLogging): exc_tb(TracebackType): exception traceback if any Returns: - Literal[False]: always False (do not suppress any exception) + Literal[False]: always ``False`` (do not suppress any exception) """ self.clear() status = BuildStatusEnum.Success if exc_val is None else BuildStatusEnum.Failed diff --git a/src/ahriman/core/alpm/pacman_database.py b/src/ahriman/core/alpm/pacman_database.py index 3c99f07c..3bbcdf72 100644 --- a/src/ahriman/core/alpm/pacman_database.py +++ b/src/ahriman/core/alpm/pacman_database.py @@ -101,7 +101,7 @@ class PacmanDatabase(SyncHttpClient): local_path(Path): path to locally stored file Returns: - bool: True in case if remote file is newer than local file + bool: ``True`` in case if remote file is newer than local file Raises: PacmanError: in case if no last-modified header was found diff --git a/src/ahriman/core/auth/auth.py b/src/ahriman/core/auth/auth.py index 8bcfa018..2fc083e4 100644 --- a/src/ahriman/core/auth/auth.py +++ b/src/ahriman/core/auth/auth.py @@ -96,7 +96,7 @@ class Auth(LazyLogging): password(str | None): entered password Returns: - bool: True in case if password matches, False otherwise + bool: ``True`` in case if password matches, ``False`` otherwise """ del username, password return True @@ -109,7 +109,7 @@ class Auth(LazyLogging): username(str): username Returns: - bool: True in case if user is known and can be authorized and False otherwise + bool: ``True`` in case if user is known and can be authorized and ``False`` otherwise """ del username return True @@ -124,7 +124,7 @@ class Auth(LazyLogging): context(str | None): URI request path Returns: - bool: True in case if user is allowed to do this request and False otherwise + bool: ``True`` in case if user is allowed to do this request and ``False`` otherwise """ del username, required, context return True diff --git a/src/ahriman/core/auth/helpers.py b/src/ahriman/core/auth/helpers.py index beb5c5b7..70a4484f 100644 --- a/src/ahriman/core/auth/helpers.py +++ b/src/ahriman/core/auth/helpers.py @@ -38,7 +38,7 @@ async def authorized_userid(*args: Any, **kwargs: Any) -> Any: **kwargs(Any): named argument list as provided by authorized_userid function Returns: - Any: None in case if no aiohttp_security module found and function call otherwise + Any: ``None`` in case if no aiohttp_security module found and function call otherwise """ if _has_aiohttp_security: return await aiohttp_security.authorized_userid(*args, **kwargs) # pylint: disable=no-value-for-parameter @@ -54,7 +54,7 @@ async def check_authorized(*args: Any, **kwargs: Any) -> Any: **kwargs(Any): named argument list as provided by authorized_userid function Returns: - Any: None in case if no aiohttp_security module found and function call otherwise + Any: ``None`` in case if no aiohttp_security module found and function call otherwise """ if _has_aiohttp_security: return await aiohttp_security.check_authorized(*args, **kwargs) # pylint: disable=no-value-for-parameter @@ -70,7 +70,7 @@ async def forget(*args: Any, **kwargs: Any) -> Any: **kwargs(Any): named argument list as provided by authorized_userid function Returns: - Any: None in case if no aiohttp_security module found and function call otherwise + Any: ``None`` in case if no aiohttp_security module found and function call otherwise """ if _has_aiohttp_security: return await aiohttp_security.forget(*args, **kwargs) # pylint: disable=no-value-for-parameter @@ -86,7 +86,7 @@ async def remember(*args: Any, **kwargs: Any) -> Any: **kwargs(Any): named argument list as provided by authorized_userid function Returns: - Any: None in case if no aiohttp_security module found and function call otherwise + Any: ``None`` in case if no aiohttp_security module found and function call otherwise """ if _has_aiohttp_security: return await aiohttp_security.remember(*args, **kwargs) # pylint: disable=no-value-for-parameter diff --git a/src/ahriman/core/auth/mapping.py b/src/ahriman/core/auth/mapping.py index e3b6f8cb..ef323496 100644 --- a/src/ahriman/core/auth/mapping.py +++ b/src/ahriman/core/auth/mapping.py @@ -57,7 +57,7 @@ class Mapping(Auth): password(str | None): entered password Returns: - bool: True in case if password matches, False otherwise + bool: ``True`` in case if password matches, ``False`` otherwise """ if password is None: return False # invalid data supplied @@ -72,7 +72,7 @@ class Mapping(Auth): username(str): username Returns: - User | None: user descriptor if username is known and None otherwise + User | None: user descriptor if username is known and ``None`` otherwise """ return self.database.user_get(username) @@ -84,7 +84,7 @@ class Mapping(Auth): username(str): username Returns: - bool: True in case if user is known and can be authorized and False otherwise + bool: ``True`` in case if user is known and can be authorized and ``False`` otherwise """ return username is not None and self.get_user(username) is not None @@ -98,7 +98,7 @@ class Mapping(Auth): context(str | None): URI request path Returns: - bool: True in case if user is allowed to do this request and False otherwise + bool: ``True`` in case if user is allowed to do this request and ``False`` otherwise """ user = self.get_user(username) return user is not None and user.verify_access(required) diff --git a/src/ahriman/core/auth/pam.py b/src/ahriman/core/auth/pam.py index 4bf4c6ec..34c1cb88 100644 --- a/src/ahriman/core/auth/pam.py +++ b/src/ahriman/core/auth/pam.py @@ -79,7 +79,7 @@ class PAM(Mapping): password(str | None): entered password Returns: - bool: True in case if password matches, False otherwise + bool: ``True`` in case if password matches, ``False`` otherwise """ if password is None: return False # invalid data supplied @@ -101,7 +101,7 @@ class PAM(Mapping): username(str): username Returns: - bool: True in case if user is known and can be authorized and False otherwise + bool: ``True`` in case if user is known and can be authorized and ``False`` otherwise """ try: _ = getpwnam(username) @@ -119,7 +119,7 @@ class PAM(Mapping): context(str | None): URI request path Returns: - bool: True in case if user is allowed to do this request and False otherwise + bool: ``True`` in case if user is allowed to do this request and ``False`` otherwise """ # this method is basically inverted, first we check overrides in database and then fallback to the PAM logic if (user := self.get_user(username)) is not None: diff --git a/src/ahriman/core/build_tools/sources.py b/src/ahriman/core/build_tools/sources.py index 234a84d6..f3dfd4b5 100644 --- a/src/ahriman/core/build_tools/sources.py +++ b/src/ahriman/core/build_tools/sources.py @@ -138,7 +138,7 @@ class Sources(LazyLogging): sources_dir(Path): local path to git repository Returns: - bool: True in case if there is any remote and false otherwise + bool: ``True`` in case if there is any remote and false otherwise """ instance = Sources() remotes = check_output(*instance.git(), "remote", cwd=sources_dir, logger=instance.logger) @@ -261,7 +261,7 @@ class Sources(LazyLogging): commit_author(tuple[str, str] | None, optional): optional commit author if any (Default value = None) Returns: - bool: True in case if changes have been committed and False otherwise + bool: ``True`` in case if changes have been committed and ``False`` otherwise """ if not self.has_changes(sources_dir): return False # nothing to commit @@ -351,7 +351,7 @@ class Sources(LazyLogging): sources_dir(Path): local path to git repository Returns: - bool: True if there are uncommitted changes and False otherwise + bool: ``True`` if there are uncommitted changes and ``False`` otherwise """ # there is --exit-code argument to diff, however, there might be other process errors changes = check_output(*self.git(), "diff", "--cached", "--name-only", cwd=sources_dir, logger=self.logger) diff --git a/src/ahriman/core/configuration/validator.py b/src/ahriman/core/configuration/validator.py index 0000dd82..d404abde 100644 --- a/src/ahriman/core/configuration/validator.py +++ b/src/ahriman/core/configuration/validator.py @@ -149,7 +149,7 @@ class Validator(RootValidator): check if paths exists Args: - constraint(bool): True in case if path must exist and False otherwise + constraint(bool): ``True`` in case if path must exist and ``False`` otherwise field(str): field name to be checked value(Path): value to be checked diff --git a/src/ahriman/core/database/operations/operations.py b/src/ahriman/core/database/operations/operations.py index b2d0631c..636d0ca5 100644 --- a/src/ahriman/core/database/operations/operations.py +++ b/src/ahriman/core/database/operations/operations.py @@ -74,7 +74,7 @@ class Operations(LazyLogging): Args: query(Callable[[Connection], T]): function to be called with connection - commit(bool, optional): if True commit() will be called on success (Default value = False) + commit(bool, optional): if ``True`` commit() will be called on success (Default value = False) Returns: T: result of the ``query`` call diff --git a/src/ahriman/core/formatters/build_printer.py b/src/ahriman/core/formatters/build_printer.py index ca2d1c6e..d8e5476d 100644 --- a/src/ahriman/core/formatters/build_printer.py +++ b/src/ahriman/core/formatters/build_printer.py @@ -32,7 +32,7 @@ class BuildPrinter(StringPrinter): Args: package(Package): built package - is_success(bool): True in case if build has success status and False otherwise + is_success(bool): ``True`` in case if build has success status and ``False`` otherwise use_utf(bool): use utf instead of normal symbols """ StringPrinter.__init__(self, f"{self.sign(is_success, use_utf)} {package.base}") @@ -43,7 +43,7 @@ class BuildPrinter(StringPrinter): generate sign according to settings Args: - is_success(bool): True in case if build has success status and False otherwise + is_success(bool): ``True`` in case if build has success status and ``False`` otherwise use_utf(bool): use utf instead of normal symbols Returns: diff --git a/src/ahriman/core/formatters/changes_printer.py b/src/ahriman/core/formatters/changes_printer.py index a0532582..84dd2a45 100644 --- a/src/ahriman/core/formatters/changes_printer.py +++ b/src/ahriman/core/formatters/changes_printer.py @@ -57,7 +57,7 @@ class ChangesPrinter(Printer): generate entry title from content Returns: - str | None: content title if it can be generated and None otherwise + str | None: content title if it can be generated and ``None`` otherwise """ if self.changes.is_empty: return None diff --git a/src/ahriman/core/formatters/printer.py b/src/ahriman/core/formatters/printer.py index 39d21e03..70ef868d 100644 --- a/src/ahriman/core/formatters/printer.py +++ b/src/ahriman/core/formatters/printer.py @@ -63,7 +63,7 @@ class Printer: generate entry title from content Returns: - str | None: content title if it can be generated and None otherwise + str | None: content title if it can be generated and ``None`` otherwise """ return None diff --git a/src/ahriman/core/formatters/string_printer.py b/src/ahriman/core/formatters/string_printer.py index 7e498534..6956708a 100644 --- a/src/ahriman/core/formatters/string_printer.py +++ b/src/ahriman/core/formatters/string_printer.py @@ -42,6 +42,6 @@ class StringPrinter(Printer): generate entry title from content Returns: - str | None: content title if it can be generated and None otherwise + str | None: content title if it can be generated and ``None`` otherwise """ return self.content diff --git a/src/ahriman/core/http/sync_http_client.py b/src/ahriman/core/http/sync_http_client.py index 824a5897..06dd2332 100644 --- a/src/ahriman/core/http/sync_http_client.py +++ b/src/ahriman/core/http/sync_http_client.py @@ -85,7 +85,7 @@ class SyncHttpClient(LazyLogging): exception(requests.RequestException): exception raised Returns: - str: text of the response if it is not None and empty string otherwise + str: text of the response if it is not ``None`` and empty string otherwise """ result: str = exception.response.text if exception.response is not None else "" return result diff --git a/src/ahriman/core/report/jinja_template.py b/src/ahriman/core/report/jinja_template.py index ab51990c..e00a366f 100644 --- a/src/ahriman/core/report/jinja_template.py +++ b/src/ahriman/core/report/jinja_template.py @@ -38,8 +38,8 @@ class JinjaTemplate: * homepage - link to homepage, string, optional * link_path - prefix fo packages to download, string, required - * has_package_signed - True in case if package sign enabled, False otherwise, required - * has_repo_signed - True in case if repository database sign enabled, False otherwise, required + * has_package_signed - ``True`` in case if package sign enabled, ``False`` otherwise, required + * has_repo_signed - ``True`` in case if repository database sign enabled, ``False`` otherwise, required * packages - sorted list of packages properties, required * architecture, string * archive_size, pretty printed size, string diff --git a/src/ahriman/core/report/remote_call.py b/src/ahriman/core/report/remote_call.py index 6294f65b..5b1a9768 100644 --- a/src/ahriman/core/report/remote_call.py +++ b/src/ahriman/core/report/remote_call.py @@ -78,7 +78,7 @@ class RemoteCall(Report): process_id(str): remote process id Returns: - bool: True in case if remote process is alive and False otherwise + bool: ``True`` in case if remote process is alive and ``False`` otherwise """ try: response = self.client.make_request("GET", f"{self.client.address}/api/v1/service/process/{process_id}") diff --git a/src/ahriman/core/spawn.py b/src/ahriman/core/spawn.py index 1a4c0d04..c77bde31 100644 --- a/src/ahriman/core/spawn.py +++ b/src/ahriman/core/spawn.py @@ -72,7 +72,7 @@ class Spawn(Thread, LazyLogging): value(bool): command line argument value Returns: - str: if ``value`` is True, then returns positive flag and negative otherwise + str: if ``value`` is ``True``, then returns positive flag and negative otherwise """ return name if value else f"no-{name}" @@ -153,7 +153,7 @@ class Spawn(Thread, LazyLogging): process_id(str): process id to be checked as returned by :func:`_spawn_process()` Returns: - bool: True in case if process still counts as active and False otherwise + bool: ``True`` in case if process still counts as active and ``False`` otherwise """ with self._lock: return process_id in self.active diff --git a/src/ahriman/core/status/client.py b/src/ahriman/core/status/client.py index 67a6401d..b349a05b 100644 --- a/src/ahriman/core/status/client.py +++ b/src/ahriman/core/status/client.py @@ -216,7 +216,7 @@ class Client: Args: package_base(str): package base - version(str | None): package version to remove logs. If None set, all logs will be removed + version(str | None): package version to remove logs. If ``None`` is set, all logs will be removed Raises: NotImplementedError: not implemented method @@ -245,7 +245,7 @@ class Client: Args: package_base(str): package base to update - variable(str | None): patch name. If None set, all patches will be removed + variable(str | None): patch name. If ``None`` is set, all patches will be removed Raises: NotImplementedError: not implemented method diff --git a/src/ahriman/core/status/local_client.py b/src/ahriman/core/status/local_client.py index 3229f0e2..6479c650 100644 --- a/src/ahriman/core/status/local_client.py +++ b/src/ahriman/core/status/local_client.py @@ -164,7 +164,7 @@ class LocalClient(Client): Args: package_base(str): package base - version(str | None): package version to remove logs. If None set, all logs will be removed + version(str | None): package version to remove logs. If ``None`` is set, all logs will be removed """ self.database.logs_remove(package_base, version, self.repository_id) @@ -188,7 +188,7 @@ class LocalClient(Client): Args: package_base(str): package base to update - variable(str | None): patch name. If None set, all patches will be removed + variable(str | None): patch name. If ``None`` is set, all patches will be removed """ variables = [variable] if variable is not None else None self.database.patches_remove(package_base, variables) diff --git a/src/ahriman/core/status/web_client.py b/src/ahriman/core/status/web_client.py index d80b47ae..ce13050a 100644 --- a/src/ahriman/core/status/web_client.py +++ b/src/ahriman/core/status/web_client.py @@ -338,7 +338,7 @@ class WebClient(Client, SyncAhrimanClient): Args: package_base(str): package base - version(str | None): package version to remove logs. If None set, all logs will be removed + version(str | None): package version to remove logs. If ``None`` is set, all logs will be removed """ query = self.repository_id.query() if version is not None: @@ -373,7 +373,7 @@ class WebClient(Client, SyncAhrimanClient): Args: package_base(str): package base to update - variable(str | None): patch name. If None set, all patches will be removed + variable(str | None): patch name. If ``None`` is set, all patches will be removed """ with contextlib.suppress(Exception): self.make_request("DELETE", self._patches_url(package_base, variable or "")) diff --git a/src/ahriman/core/tree.py b/src/ahriman/core/tree.py index 28e2fb97..dd2b3f9b 100644 --- a/src/ahriman/core/tree.py +++ b/src/ahriman/core/tree.py @@ -64,7 +64,7 @@ class Leaf: packages(Iterable[Leaf]): list of known leaves Returns: - bool: True in case if package is dependency of others and False otherwise + bool: ``True`` in case if package is dependency of others and ``False`` otherwise """ for leaf in packages: if leaf.dependencies.intersection(self.items): @@ -79,7 +79,7 @@ class Leaf: packages(Iterable[Leaf]): list of known leaves Returns: - bool: True if any of packages is dependency of the leaf, False otherwise + bool: ``True`` if any of packages is dependency of the leaf, ``False`` otherwise """ for leaf in packages: if self.dependencies.intersection(leaf.items): diff --git a/src/ahriman/core/upload/github.py b/src/ahriman/core/upload/github.py index a0916385..605c2cc9 100644 --- a/src/ahriman/core/upload/github.py +++ b/src/ahriman/core/upload/github.py @@ -160,7 +160,7 @@ class GitHub(Upload, HttpUpload): get release object if any Returns: - dict[str, Any] | None: GitHub API release object if release found and None otherwise + dict[str, Any] | None: GitHub API release object if release found and ``None`` otherwise """ url = f"https://api.github.com/repos/{self.github_owner}/{ self.github_repository}/releases/tags/{self.github_release_tag}" diff --git a/src/ahriman/core/utils.py b/src/ahriman/core/utils.py index fac8e6c0..ab1651ef 100644 --- a/src/ahriman/core/utils.py +++ b/src/ahriman/core/utils.py @@ -225,8 +225,8 @@ def extract_user() -> str | None: extract user from system environment Returns: - str | None: SUDO_USER in case if set and USER otherwise. It can return None in case if environment has been - cleared before application start + str | None: SUDO_USER in case if set and USER otherwise. It can return ``None`` in case if environment has been + cleared before application start """ return os.getenv("SUDO_USER") or os.getenv("DOAS_USER") or os.getenv("USER") @@ -295,7 +295,7 @@ def package_like(filename: Path) -> bool: filename(Path): name of file to check Returns: - bool: True in case if name contains ``.pkg.`` and not signature, False otherwise + bool: ``True`` in case if name contains ``.pkg.`` and not signature, ``False`` otherwise """ name = filename.name return not name.startswith(".") and ".pkg." in name and not name.endswith(".sig") diff --git a/src/ahriman/models/auth_settings.py b/src/ahriman/models/auth_settings.py index 094bd0e5..69906668 100644 --- a/src/ahriman/models/auth_settings.py +++ b/src/ahriman/models/auth_settings.py @@ -44,7 +44,7 @@ class AuthSettings(StrEnum): get enabled flag Returns: - bool: False in case if authorization is disabled and True otherwise + bool: ``False`` in case if authorization is disabled and ``True`` otherwise """ return self != AuthSettings.Disabled diff --git a/src/ahriman/models/event.py b/src/ahriman/models/event.py index 7b5e970b..201e166c 100644 --- a/src/ahriman/models/event.py +++ b/src/ahriman/models/event.py @@ -29,11 +29,15 @@ class EventType(StrEnum): predefined event types Attributes: + PackageOutdated(EventType): (class attribute) package has been marked as out-of-date PackageRemoved(EventType): (class attribute) package has been removed + PackageUpdateFailed(EventType): (class attribute) package update has been failed PackageUpdated(EventType): (class attribute) package has been updated """ + PackageOutdated = "package-outdated" PackageRemoved = "package-removed" + PackageUpdateFailed = "package-update-failed" PackageUpdated = "package-updated" @@ -58,11 +62,10 @@ class Event: def __post_init__(self) -> None: """ - replace null data to empty dictionary + convert event type to enum if it is a well-known event type """ if self.event in EventType: object.__setattr__(self, "event", EventType(self.event)) - object.__setattr__(self, "data", self.data or {}) @classmethod def from_json(cls, dump: dict[str, Any]) -> Self: diff --git a/src/ahriman/models/migration_result.py b/src/ahriman/models/migration_result.py index 6000e5ca..3a0ab84e 100644 --- a/src/ahriman/models/migration_result.py +++ b/src/ahriman/models/migration_result.py @@ -41,7 +41,7 @@ class MigrationResult: check migration and check if there are pending migrations Returns: - bool: True in case if it requires migrations and False otherwise + bool: ``True`` in case if it requires migrations and ``False`` otherwise """ self.validate() return self.new_version > self.old_version diff --git a/src/ahriman/models/package.py b/src/ahriman/models/package.py index adfd7296..6016099f 100644 --- a/src/ahriman/models/package.py +++ b/src/ahriman/models/package.py @@ -158,7 +158,7 @@ class Package(LazyLogging): get VCS flag based on the package base Returns: - bool: True in case if package base looks like VCS package and False otherwise + bool: ``True`` in case if package base looks like VCS package and ``False`` otherwise """ return self.base.endswith("-bzr") \ or self.base.endswith("-csv")\ @@ -504,7 +504,7 @@ class Package(LazyLogging): timestamp(float | int): timestamp to check build date against Returns: - bool: True in case if package was built after the specified date and False otherwise. In case if build date + bool: ``True`` in case if package was built after the specified date and ``False`` otherwise. In case if build date is not set by any of packages, it returns False """ return any( @@ -528,7 +528,7 @@ class Package(LazyLogging): (Default value = True) Returns: - bool: True if the package is out-of-dated and False otherwise + bool: ``True`` if the package is out-of-dated and ``False`` otherwise """ min_vcs_build_date = utcnow().timestamp() - vcs_allowed_age if calculate_version and not self.is_newer_than(min_vcs_build_date): diff --git a/src/ahriman/models/pkgbuild_patch.py b/src/ahriman/models/pkgbuild_patch.py index 3a809b12..808ac8cb 100644 --- a/src/ahriman/models/pkgbuild_patch.py +++ b/src/ahriman/models/pkgbuild_patch.py @@ -55,7 +55,7 @@ class PkgbuildPatch: parse key and define whether it function or not Returns: - bool: True in case if key ends with parentheses and False otherwise + bool: ``True`` in case if key ends with parentheses and ``False`` otherwise """ return self.key is not None and self.key.endswith("()") @@ -65,7 +65,7 @@ class PkgbuildPatch: check if patch is full diff one or just single-variable patch Returns: - bool: True in case key set and False otherwise + bool: ``True`` in case key set and ``False`` otherwise """ return self.key is None diff --git a/src/ahriman/models/property.py b/src/ahriman/models/property.py index 7bc2f990..909d8334 100644 --- a/src/ahriman/models/property.py +++ b/src/ahriman/models/property.py @@ -29,7 +29,7 @@ class Property: Attributes: name(str): name of the property value(Any): property value - is_required(bool): if set to True then this property is required + is_required(bool): if set to ``True`` then this property is required indent(int): property indentation level """ diff --git a/src/ahriman/models/remote_source.py b/src/ahriman/models/remote_source.py index 1446a969..3de33abd 100644 --- a/src/ahriman/models/remote_source.py +++ b/src/ahriman/models/remote_source.py @@ -57,7 +57,7 @@ class RemoteSource: check if source is remote Returns: - bool: True in case if package is well-known remote source (e.g. AUR) and False otherwise + bool: ``True`` in case if package is well-known remote source (e.g. AUR) and ``False`` otherwise """ return self.source in (PackageSource.AUR, PackageSource.Repository) diff --git a/src/ahriman/models/repository_id.py b/src/ahriman/models/repository_id.py index b8abfe6c..bb54ff64 100644 --- a/src/ahriman/models/repository_id.py +++ b/src/ahriman/models/repository_id.py @@ -52,7 +52,7 @@ class RepositoryId: check if all data is supplied for the loading Returns: - bool: True in case if architecture or name are not set and False otherwise + bool: ``True`` in case if architecture or name are not set and ``False`` otherwise """ return not self.architecture or not self.name @@ -85,7 +85,7 @@ class RepositoryId: other(Any): other object to compare Returns: - bool: True in case if this is less than other and False otherwise + bool: ``True`` in case if this is less than other and ``False`` otherwise Raises: TypeError: if other is different from RepositoryId type diff --git a/src/ahriman/models/result.py b/src/ahriman/models/result.py index 38c9a407..d209fcd0 100644 --- a/src/ahriman/models/result.py +++ b/src/ahriman/models/result.py @@ -82,7 +82,7 @@ class Result: get if build result is empty or not Returns: - bool: True in case if success list is empty and False otherwise + bool: ``True`` in case if success list is empty and ``False`` otherwise """ return not self._added and not self._updated @@ -191,7 +191,7 @@ class Result: other(Any): other object instance Returns: - bool: True if the other object is the same and False otherwise + bool: ``True`` if the other object is the same and ``False`` otherwise """ if not isinstance(other, Result): return False diff --git a/src/ahriman/models/user.py b/src/ahriman/models/user.py index 399c670d..e83deac3 100644 --- a/src/ahriman/models/user.py +++ b/src/ahriman/models/user.py @@ -98,7 +98,7 @@ class User: salt(str): salt for hashed password Returns: - bool: True in case if password matches, False otherwise + bool: ``True`` in case if password matches, ``False`` otherwise """ try: verified: bool = self._HASHER.verify(password + salt, self.password) @@ -131,7 +131,7 @@ class User: required(UserAccess): required access level Returns: - bool: True in case if user is allowed to do this request and False otherwise + bool: ``True`` in case if user is allowed to do this request and ``False`` otherwise """ return self.access.permits(required) diff --git a/src/ahriman/models/user_access.py b/src/ahriman/models/user_access.py index 4eb2e357..90049bae 100644 --- a/src/ahriman/models/user_access.py +++ b/src/ahriman/models/user_access.py @@ -47,7 +47,7 @@ class UserAccess(StrEnum): other(UserAccess): other permission to compare Returns: - bool: True in case if current permission allows the operation and False otherwise + bool: ``True`` in case if current permission allows the operation and ``False`` otherwise """ for member in UserAccess: if member == other: diff --git a/src/ahriman/web/middlewares/auth_handler.py b/src/ahriman/web/middlewares/auth_handler.py index aa5ecee9..66a2c54c 100644 --- a/src/ahriman/web/middlewares/auth_handler.py +++ b/src/ahriman/web/middlewares/auth_handler.py @@ -63,7 +63,7 @@ class _AuthorizationPolicy(aiohttp_security.AbstractAuthorizationPolicy): identity(str): username Returns: - str | None: user identity (username) in case if user exists and None otherwise + str | None: user identity (username) in case if user exists and ``None`` otherwise """ return identity if await self.validator.known_username(identity) else None @@ -77,7 +77,7 @@ class _AuthorizationPolicy(aiohttp_security.AbstractAuthorizationPolicy): context(str | None, optional): URI request path (Default value = None) Returns: - bool: True in case if user is allowed to perform this request and False otherwise + bool: ``True`` in case if user is allowed to perform this request and ``False`` otherwise """ # some methods for type checking and parent class compatibility if identity is None or not isinstance(permission, UserAccess): diff --git a/src/ahriman/web/middlewares/exception_handler.py b/src/ahriman/web/middlewares/exception_handler.py index 41082d28..fceaa5b9 100644 --- a/src/ahriman/web/middlewares/exception_handler.py +++ b/src/ahriman/web/middlewares/exception_handler.py @@ -38,7 +38,7 @@ def _is_templated_unauthorized(request: Request) -> bool: request(Request): source request to check Returns: - bool: True in case if response should be rendered as html and False otherwise + bool: ``True`` in case if response should be rendered as html and ``False`` otherwise """ return request.path in ("/api/v1/login", "/api/v1/logout") \ and "application/json" not in request.headers.getall("accept", []) diff --git a/src/ahriman/web/views/base.py b/src/ahriman/web/views/base.py index 6807175a..942177c5 100644 --- a/src/ahriman/web/views/base.py +++ b/src/ahriman/web/views/base.py @@ -247,7 +247,7 @@ class BaseView(View, CorsViewMixin): extract username from request if any Returns: - str | None: authorized username if any and None otherwise (e.g. if authorization is disabled) + str | None: authorized username if any and ``None`` otherwise (e.g. if authorization is disabled) """ try: # try to read from payload data: dict[str, str] = await self.request.json() # technically it is not, but we only need str here diff --git a/tests/ahriman/models/test_event.py b/tests/ahriman/models/test_event.py index e9f4969c..0de5377d 100644 --- a/tests/ahriman/models/test_event.py +++ b/tests/ahriman/models/test_event.py @@ -3,9 +3,9 @@ from ahriman.models.event import Event, EventType def test_post_init() -> None: """ - must remove replace empty dictionary + must replace event type for known types """ - assert Event("", "").data == {} + assert Event("random", "") assert isinstance(Event(str(EventType.PackageUpdated), "").event, EventType)