From a0dae93ae6ffcc40ea9a5ecd98a5190e8e7d00dc Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Mon, 3 Feb 2025 18:59:23 +0000 Subject: [PATCH] Use Optional for type hints to ensure backward compatibility. Replaced PEP 604 union syntax (|) with Optional for type hints to maintain compatibility with Python versions earlier than 3.10. --- src/pytest_replay/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pytest_replay/__init__.py b/src/pytest_replay/__init__.py index 81b9bc0..7632f54 100644 --- a/src/pytest_replay/__init__.py +++ b/src/pytest_replay/__init__.py @@ -6,6 +6,7 @@ from dataclasses import asdict from glob import glob from typing import Any +from typing import Optional import pytest @@ -47,8 +48,8 @@ def pytest_addoption(parser): class ReplayTestMetadata: nodeid: str start: float = 0.0 - finish: float | None = None - outcome: str | None = None + finish: Optional[float] = None + outcome: Optional[str] = None metadata: dict[str, Any] = dataclasses.field(default_factory=dict) def to_clean_dict(self) -> dict[str, Any]: @@ -160,8 +161,6 @@ def pytest_collection_modifyitems(self, items, config): config.hook.pytest_deselected(items=deselected) items[:] = remaining - # for nodeid in remaining: - # self.nodes[nodeid].metadata = def append_test_to_script(self, nodeid, line): suffix = "-" + self.xdist_worker_name if self.xdist_worker_name else ""