Skip to content

Commit aa87871

Browse files
committed
Align typed fixture alias with runtime decorator
1 parent b619978 commit aa87871

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

app/tests/conftest.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import os
22
import time
3-
from typing import Any, Callable, Optional, TypeVar, cast
3+
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar
44
from urllib.parse import quote_plus
55

66
import pytest
77

88
os.environ.setdefault("OTEL_SDK_DISABLED", "true")
99

10-
F = TypeVar("F", bound=Callable[..., object])
10+
if TYPE_CHECKING:
11+
F = TypeVar("F", bound=Callable[..., object])
1112

13+
def typed_fixture(*args: Any, **kwargs: Any) -> Callable[[F], F]:
14+
def decorator(func: F) -> F:
15+
return func
1216

13-
def typed_fixture(*args: Any, **kwargs: Any) -> Callable[[F], F]:
14-
"""Typed veneer over pytest.fixture to keep mypy happy while preserving runtime behavior."""
15-
fixture_factory = pytest.fixture(*args, **kwargs)
17+
return decorator
1618

17-
def decorator(func: F) -> F:
18-
return cast(F, fixture_factory(func))
19-
20-
return decorator
19+
else:
20+
typed_fixture = pytest.fixture
2121

2222

2323
TRANSIENT_CODES = {

0 commit comments

Comments
 (0)