Skip to content

Commit

Permalink
Fix span context manager typing by using ParamSpec from typing_extens…
Browse files Browse the repository at this point in the history
…ions (#4389)
  • Loading branch information
aabmass authored Jan 17, 2025
1 parent 59b225f commit 58f2d16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4353](/~https://github.com/open-telemetry/opentelemetry-python/pull/4353))
- sdk: don't log or print warnings when the SDK has been disabled
([#4371](/~https://github.com/open-telemetry/opentelemetry-python/pull/4371))
- Fix span context manager typing by using ParamSpec from typing_extensions
([#4389](/~https://github.com/open-telemetry/opentelemetry-python/pull/4389))

## Version 1.29.0/0.50b0 (2024-12-11)

Expand Down
14 changes: 8 additions & 6 deletions opentelemetry-api/src/opentelemetry/util/_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
import asyncio
import contextlib
import functools
import typing
from typing import Callable, Generic, Iterator, TypeVar
from typing import TYPE_CHECKING, Callable, Generic, Iterator, TypeVar

V = TypeVar("V")
R = TypeVar("R") # Return type
Pargs = TypeVar("Pargs") # Generic type for arguments
Pkwargs = TypeVar("Pkwargs") # Generic type for arguments

if hasattr(typing, "ParamSpec"):
# only available in python 3.10+
# https://peps.python.org/pep-0612/
P = typing.ParamSpec("P") # Generic type for all arguments
# We don't actually depend on typing_extensions but we can use it in CI with this conditional
# import. ParamSpec can be imported directly from typing after python 3.9 is dropped
# https://peps.python.org/pep-0612/.
if TYPE_CHECKING:
from typing_extensions import ParamSpec

P = ParamSpec("P") # Generic type for all arguments


class _AgnosticContextManager(
Expand Down

0 comments on commit 58f2d16

Please sign in to comment.