From 7da39d123a4100db689652f6d3d594b0131a3ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Tue, 7 Oct 2025 11:40:03 -0600 Subject: [PATCH] Fix internal error when processing warnings Closes https://github.com/pytest-dev/pytest-github-actions-annotate-failures/issues/106. --- CHANGELOG.md | 1 + pytest_github_actions_annotate_failures/plugin.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dec961..c733feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Fix internal error when processing warnings #117 - Test on Python 3.14 #115 ## 0.3.0 (2025-01-17) diff --git a/pytest_github_actions_annotate_failures/plugin.py b/pytest_github_actions_annotate_failures/plugin.py index 3f58b95..7f2f4cf 100644 --- a/pytest_github_actions_annotate_failures/plugin.py +++ b/pytest_github_actions_annotate_failures/plugin.py @@ -10,6 +10,8 @@ from packaging import version if TYPE_CHECKING: + from warnings import WarningMessage + from _pytest.nodes import Item from _pytest.reports import CollectReport @@ -98,7 +100,13 @@ def compute_path(filesystempath: str) -> str: class _AnnotateWarnings: - def pytest_warning_recorded(self, warning_message, when, nodeid, location): # noqa: ARG002 + def pytest_warning_recorded( + self, + warning_message: WarningMessage, + when: str, # noqa: ARG002 + nodeid: str, # noqa: ARG002 + location: tuple[str, int, str], # noqa: ARG002 + ): # enable only in a workflow of GitHub Actions # ref: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables if os.environ.get("GITHUB_ACTIONS") != "true": @@ -124,7 +132,7 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location): # n "warning", filesystempath, warning_message.lineno, - message=warning_message.message.args[0], + message=str(warning_message.message), ) print(workflow_command, file=sys.stderr)