Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix internal error when processing warnings #117
- Test on Python 3.14 #115

## 0.3.0 (2025-01-17)
Expand Down
12 changes: 10 additions & 2 deletions pytest_github_actions_annotate_failures/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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":
Expand All @@ -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)

Expand Down