Compare commits

...

3 Commits

Author SHA1 Message Date
415fcf58ce Release 2.20.0rc4 2026-02-21 12:52:51 +02:00
17a2d6362c style: replace """ with " for single line strings 2026-02-21 12:51:58 +02:00
e6275de4ed fix: handle class overrides for retry polices correctly
Previous implementation didn't work as intended because there was still
override in init. Current implementation instead of playing with
guessing separates default and instance setttings. Also update test
cases to handle this scenario correctly
2026-02-21 12:40:11 +02:00
11 changed files with 37 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
pkgbase='ahriman'
pkgname=('ahriman' 'ahriman-core' 'ahriman-triggers' 'ahriman-web')
pkgver=2.20.0rc3
pkgver=2.20.0rc4
pkgrel=1
pkgdesc="ArcH linux ReposItory MANager"
arch=('any')

View File

@@ -1,4 +1,4 @@
.TH AHRIMAN "1" "2026\-02\-20" "ahriman 2.20.0rc3" "ArcH linux ReposItory MANager"
.TH AHRIMAN "1" "2026\-02\-21" "ahriman 2.20.0rc4" "ArcH linux ReposItory MANager"
.SH NAME
ahriman \- ArcH linux ReposItory MANager
.SH SYNOPSIS

View File

@@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__version__ = "2.20.0rc3"
__version__ = "2.20.0rc4"

View File

@@ -251,7 +251,7 @@ class Setup(Handler):
content = f"PACKAGER='{packager}'\n"
if makeflags_jobs:
content += """MAKEFLAGS="-j$(nproc)"\n"""
content += "MAKEFLAGS=\"-j$(nproc)\"\n"
uid, _ = paths.root_owner
home_dir = Path(getpwuid(uid).pw_dir)

View File

@@ -69,8 +69,8 @@ class OAuth(Mapping):
Returns:
str: login control as html code to insert
"""
return f"""<a class="nav-link" href="/api/v1/login" title="login via OAuth2"><i class="bi bi-{
self.icon}"></i> login</a>"""
return f"<a class=\"nav-link\" href=\"/api/v1/login\" title=\"login via OAuth2\"><i class=\"bi bi-{
self.icon}\"></i> login</a>"
@staticmethod
def get_provider(name: str) -> type[aioauth_client.OAuth2Client]:

View File

@@ -22,7 +22,7 @@ import sys
from functools import cached_property
from requests.adapters import BaseAdapter, HTTPAdapter
from typing import Any, IO, Literal
from typing import Any, ClassVar, IO, Literal
from urllib3.util.retry import Retry
from ahriman import __version__
@@ -39,14 +39,18 @@ class SyncHttpClient(LazyLogging):
wrapper around requests library to reduce boilerplate
Attributes:
DEFAULT_MAX_RETRIES(int): (class attribute) default maximum amount of retries
DEFAULT_RETRY_BACKOFF(float): (class attribute) default retry exponential backoff
DEFAULT_TIMEOUT(int | None): (class attribute) default HTTP request timeout in seconds
auth(tuple[str, str] | None): HTTP basic auth object if set
retry(Retry): retry policy of the HTTP client. Disabled by default
retry(Retry): retry policy of the HTTP client
suppress_errors(bool): suppress logging of request errors
timeout(int | None): HTTP request timeout in seconds
"""
retry: Retry = Retry()
timeout: int | None = None
DEFAULT_MAX_RETRIES: ClassVar[int] = 0
DEFAULT_RETRY_BACKOFF: ClassVar[float] = 0.0
DEFAULT_TIMEOUT: ClassVar[int | None] = 30
def __init__(self, configuration: Configuration | None = None, section: str | None = None, *,
suppress_errors: bool = False) -> None:
@@ -65,10 +69,10 @@ class SyncHttpClient(LazyLogging):
self.suppress_errors = suppress_errors
self.timeout = configuration.getint(section, "timeout", fallback=30)
self.timeout = configuration.getint(section, "timeout", fallback=self.DEFAULT_TIMEOUT)
self.retry = SyncHttpClient.retry_policy(
max_retries=configuration.getint(section, "max_retries", fallback=0),
retry_backoff=configuration.getfloat(section, "retry_backoff", fallback=0.0),
max_retries=configuration.getint(section, "max_retries", fallback=self.DEFAULT_MAX_RETRIES),
retry_backoff=configuration.getfloat(section, "retry_backoff", fallback=self.DEFAULT_RETRY_BACKOFF),
)
@cached_property

View File

@@ -88,11 +88,9 @@ class Repository(Executor, UpdateHandler):
Args:
configuration(Configuration): configuration instance
"""
AUR.timeout = configuration.getint("aur", "timeout", fallback=30)
AUR.retry = AUR.retry_policy(
max_retries=configuration.getint("aur", "max_retries", fallback=0),
retry_backoff=configuration.getfloat("aur", "retry_backoff", fallback=0.0),
)
AUR.DEFAULT_MAX_RETRIES = configuration.getint("aur", "max_retries", fallback=0)
AUR.DEFAULT_RETRY_BACKOFF = configuration.getfloat("aur", "retry_backoff", fallback=0.0)
AUR.DEFAULT_TIMEOUT = configuration.getint("aur", "timeout", fallback=30)
def _set_context(self) -> None:
"""

View File

@@ -375,7 +375,7 @@ class Package(LazyLogging):
Returns:
str: print-friendly string
"""
details = "" if self.is_single_package else f""" ({" ".join(sorted(self.packages.keys()))})"""
details = "" if self.is_single_package else f" ({" ".join(sorted(self.packages.keys()))})"
return f"{self.base}{details}"
def vercmp(self, version: str) -> int:

View File

@@ -147,7 +147,7 @@ class PkgbuildPatch:
"""
if "$" in source:
# copy from library method with double quotes instead
return f"""\"{source.replace("\"", "'\"'")}\""""
return f"\"{source.replace("\"", "'\"'")}\""
# otherwise just return normal call
return shlex.quote(source)
@@ -195,13 +195,13 @@ class PkgbuildPatch:
"""
if isinstance(self.value, list): # list like
value = " ".join(map(self.quote, self.value))
return f"""{self.key}=({value})"""
return f"{self.key}=({value})"
if self.is_plain_diff: # no additional logic for plain diffs
return self.value
# we suppose that function values are only supported in string-like values
if self.is_function:
return f"{self.key} {self.value}" # no quoting enabled here
return f"""{self.key}={self.quote(self.value)}"""
return f"{self.key}={self.quote(self.value)}"
def substitute(self, variables: dict[str, str]) -> str | list[str]:
"""

View File

@@ -49,14 +49,18 @@ def test_retry_policy() -> None:
"""
must set retry policy
"""
SyncHttpClient.retry = SyncHttpClient.retry_policy(1, 2.0)
AUR.retry = AUR.retry_policy(3, 4.0)
SyncHttpClient.DEFAULT_MAX_RETRIES = 1
SyncHttpClient.DEFAULT_RETRY_BACKOFF = 2.0
AUR.DEFAULT_MAX_RETRIES = 3
AUR.DEFAULT_RETRY_BACKOFF = 4.0
assert SyncHttpClient.retry.connect == 1
assert SyncHttpClient.retry.backoff_factor == 2.0
client = SyncHttpClient()
assert client.retry.connect == 1
assert client.retry.backoff_factor == 2.0
assert AUR.retry.connect == 3
assert AUR.retry.backoff_factor == 4.0
aur = AUR()
assert aur.retry.connect == 3
assert aur.retry.backoff_factor == 4.0
def test_exception_response_text() -> None:

View File

@@ -31,8 +31,9 @@ def test_set_globals(configuration: Configuration) -> None:
configuration.set_option("aur", "max_retries", "10")
Repository._set_globals(configuration)
assert AUR.timeout == 42
assert AUR.retry.connect == 10
aur = AUR()
assert aur.timeout == 42
assert aur.retry.connect == 10
def test_set_context(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> None: