From 56899cd29cc5efd3bcd78e11f843b12138e872a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 30 Apr 2024 17:38:50 +0200 Subject: [PATCH] fix printing errors in project reload hooks --- buildbot_nix/gitea_projects.py | 10 ++++++---- buildbot_nix/github_projects.py | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/buildbot_nix/gitea_projects.py b/buildbot_nix/gitea_projects.py index b343e8b..a951f95 100644 --- a/buildbot_nix/gitea_projects.py +++ b/buildbot_nix/gitea_projects.py @@ -5,7 +5,7 @@ from collections.abc import Generator from dataclasses import dataclass from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Any +from typing import Any, TYPE_CHECKING from buildbot.config.builder import BuilderConfig from buildbot.plugins import util @@ -20,6 +20,9 @@ from twisted.internet import defer, threads from twisted.python import log from twisted.python.failure import Failure +if TYPE_CHECKING: + from buildbot.process.log import StreamLog + from .common import ( http_request, paginated_github_request, @@ -259,9 +262,8 @@ class ReloadGiteaProjects(BuildStep): os.kill(os.getpid(), signal.SIGHUP) return util.SUCCESS else: - yield self.addLog("log").addStderr( - f"Failed to reload project list: {self.error_msg}" - ) + log: StreamLog = yield self.addLog("log") + log.addStderr(f"Failed to reload project list: {self.error_msg}") return util.FAILURE diff --git a/buildbot_nix/github_projects.py b/buildbot_nix/github_projects.py index ded8dd1..a2c2ef8 100644 --- a/buildbot_nix/github_projects.py +++ b/buildbot_nix/github_projects.py @@ -5,7 +5,7 @@ from collections.abc import Generator from dataclasses import dataclass from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Any +from typing import TYPE_CHECKING, Any from buildbot.config.builder import BuilderConfig from buildbot.plugins import util @@ -20,6 +20,9 @@ from twisted.internet import defer, threads from twisted.python import log from twisted.python.failure import Failure +if TYPE_CHECKING: + from buildbot.process.log import StreamLog + from .common import ( http_request, paginated_github_request, @@ -57,9 +60,8 @@ class ReloadGithubProjects(BuildStep): os.kill(os.getpid(), signal.SIGHUP) return util.SUCCESS else: - yield self.addLog("log").addStderr( - f"Failed to reload project list: {self.error_msg}" - ) + log: StreamLog = yield self.addLog("log") + log.addStderr(f"Failed to reload project list: {self.error_msg}") return util.FAILURE