Skip to content

chore: replace "deprecated" packages with PEP702 #4522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor `BatchLogRecordProcessor` to simplify code and make the control flow more
clear ([#4562](https://github.com/open-telemetry/opentelemetry-python/pull/4562/)
and [#4535](https://github.com/open-telemetry/opentelemetry-python/pull/4535)).
- Use PEP702 for marking deprecations
([#4522](https://github.com/open-telemetry/opentelemetry-python/pull/4522))

## Version 1.33.0/0.54b0 (2025-05-09)

Expand Down
3 changes: 1 addition & 2 deletions docs/examples/metrics/reader/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Deprecated==1.2.13
opentelemetry-api==1.15.0
opentelemetry-sdk==1.15.0
opentelemetry-semantic-conventions==0.36b0
typing_extensions==4.3.0
typing_extensions==4.5.0
wrapt==1.14.1
3 changes: 1 addition & 2 deletions docs/examples/metrics/views/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Deprecated==1.2.13
opentelemetry-api==1.12.0
opentelemetry-sdk==1.12.0
opentelemetry-semantic-conventions==0.33b0
typing_extensions==4.3.0
typing_extensions==4.5.0
wrapt==1.14.1
1 change: 0 additions & 1 deletion docs/getting_started/tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ attrs==23.1.0
certifi==2024.7.4
charset-normalizer==2.0.12
click==8.1.7
Deprecated==1.2.14
Flask==2.3.3
idna==3.7
importlib-metadata==6.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
grpcio==1.66.2
importlib-metadata==6.11.0
iniconfig==2.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
dependencies = [
"Deprecated >= 1.2.6",
"googleapis-common-protos ~= 1.52",
"grpcio >= 1.63.2, < 2.0.0; python_version < '3.13'",
"grpcio >= 1.66.2, < 2.0.0; python_version >= '3.13'",
"opentelemetry-api ~= 1.15",
"opentelemetry-proto == 1.34.0.dev",
"opentelemetry-sdk ~= 1.34.0.dev",
"opentelemetry-exporter-otlp-proto-common == 1.34.0.dev",
"typing-extensions >= 4.5.0",
]

[project.entry-points.opentelemetry_logs_exporter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from typing import Sequence as TypingSequence
from urllib.parse import urlparse

from deprecated import deprecated
from google.rpc.error_details_pb2 import RetryInfo
from typing_extensions import deprecated

from grpc import (
ChannelCredentials,
Expand Down Expand Up @@ -108,8 +108,7 @@ def environ_to_compression(environ_key: str) -> Optional[Compression]:


@deprecated(
version="1.18.0",
reason="Use one of the encoders from opentelemetry-exporter-otlp-proto-common instead",
"Use one of the encoders from opentelemetry-exporter-otlp-proto-common instead. Deprecated since version 1.18.0.",
)
def get_resource_data(
sdk_resource_scope_data: Dict[SDKResource, ResourceDataT],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
googleapis-common-protos==1.63.2
grpcio==1.66.2
importlib-metadata==6.11.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
dependencies = [
"Deprecated >= 1.2.6",
"googleapis-common-protos ~= 1.52",
"opentelemetry-api ~= 1.15",
"opentelemetry-proto == 1.34.0.dev",
"opentelemetry-sdk ~= 1.34.0.dev",
"opentelemetry-exporter-otlp-proto-common == 1.34.0.dev",
"requests ~= 2.7",
"typing-extensions >= 4.5.0",
]

[project.entry-points.opentelemetry_traces_exporter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
)

import requests
from deprecated import deprecated
from requests.exceptions import ConnectionError
from typing_extensions import deprecated

from opentelemetry.exporter.otlp.proto.common._internal import (
_create_exp_backoff_generator,
Expand Down Expand Up @@ -253,8 +253,7 @@ def force_flush(self, timeout_millis: float = 10_000) -> bool:


@deprecated(
version="1.18.0",
reason="Use one of the encoders from opentelemetry-exporter-otlp-proto-common instead",
"Use one of the encoders from opentelemetry-exporter-otlp-proto-common instead. Deprecated since version 1.18.0.",
)
def get_resource_data(
sdk_resource_scope_data: Dict[SDKResource, Any], # ResourceDataT?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
asgiref==3.7.2
certifi==2024.7.4
charset-normalizer==3.3.2
Deprecated==1.2.14
googleapis-common-protos==1.63.2
idna==3.7
importlib-metadata==6.11.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
asgiref==3.7.2
certifi==2024.7.4
charset-normalizer==3.3.2
Deprecated==1.2.14
idna==3.7
importlib-metadata==6.11.0
iniconfig==2.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
asgiref==3.7.2
certifi==2024.7.4
charset-normalizer==3.3.2
Deprecated==1.2.14
idna==3.7
importlib-metadata==6.11.0
iniconfig==2.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"Deprecated >= 1.2.6",
"typing-extensions >= 4.5.0",
# FIXME This should be able to be removed after 3.12 is released if there is a reliable API
# in importlib.metadata.
"importlib-metadata >= 6.0, < 8.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging
import typing

from deprecated import deprecated
from typing_extensions import deprecated

from opentelemetry.context.context import Context
from opentelemetry.propagators import textmap
Expand Down Expand Up @@ -84,7 +84,9 @@ def fields(self) -> typing.Set[str]:
return composite_fields


@deprecated(version="1.2.0", reason="You should use CompositePropagator") # type: ignore
@deprecated(
"You should use CompositePropagator. Deprecated since version 1.2.0."
)
class CompositeHTTPPropagator(CompositePropagator):
"""CompositeHTTPPropagator provides a mechanism for combining multiple
propagators into a single one.
Expand Down
8 changes: 5 additions & 3 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
from logging import getLogger
from typing import Iterator, Optional, Sequence, cast

from deprecated import deprecated
from typing_extensions import deprecated

from opentelemetry import context as context_api
from opentelemetry.attributes import BoundedAttributes
Expand Down Expand Up @@ -244,7 +244,9 @@ def get_tracer(
return NoOpTracer()


@deprecated(version="1.9.0", reason="You should use NoOpTracerProvider") # type: ignore
@deprecated(
"You should use NoOpTracerProvider. Deprecated since version 1.9.0."
)
class _DefaultTracerProvider(NoOpTracerProvider):
"""The default TracerProvider, used when no implementation is available.

Expand Down Expand Up @@ -487,7 +489,7 @@ def start_as_current_span(
yield INVALID_SPAN


@deprecated(version="1.9.0", reason="You should use NoOpTracer") # type: ignore
@deprecated("You should use NoOpTracer. Deprecated since version 1.9.0.")
class _DefaultTracer(NoOpTracer):
"""The default Tracer, used when no Tracer implementation is available.

Expand Down
6 changes: 4 additions & 2 deletions opentelemetry-api/src/opentelemetry/util/re.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Dict, List, Mapping
from urllib.parse import unquote

from deprecated import deprecated
from typing_extensions import deprecated

_logger = getLogger(__name__)

Expand Down Expand Up @@ -59,7 +59,9 @@
# pylint: disable=invalid-name


@deprecated(version="1.15.0", reason="You should use parse_env_headers") # type: ignore
@deprecated(
"You should use parse_env_headers. Deprecated since version 1.15.0."
)
def parse_headers(s: str) -> Mapping[str, str]:
return parse_env_headers(s)

Expand Down
1 change: 0 additions & 1 deletion opentelemetry-api/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==8.5.0 ; python_version < "3.9"
importlib-metadata==8.6.1 ; python_version >= "3.9"
iniconfig==2.0.0
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-proto/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classifiers = [
dependencies = [
"opentelemetry-api == 1.34.0.dev",
"opentelemetry-semantic-conventions == 0.55b0.dev",
"typing-extensions >= 3.7.4",
"typing-extensions >= 4.5.0",
]

[project.entry-points.opentelemetry_environment_variables]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# type: ignore[reportDeprecated] # ResourceAttributes is deprecated

"""
This package implements `OpenTelemetry Resources
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-sdk>`_:
Expand Down
7 changes: 3 additions & 4 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)
from warnings import filterwarnings

from deprecated import deprecated
from typing_extensions import deprecated

from opentelemetry import context as context_api
from opentelemetry import trace as trace_api
Expand Down Expand Up @@ -474,7 +474,7 @@ def resource(self) -> Resource:

@property
@deprecated(
version="1.11.1", reason="You should use instrumentation_scope"
"You should use instrumentation_scope. Deprecated since version 1.11.1."
)
def instrumentation_info(self) -> Optional[InstrumentationInfo]:
return self._instrumentation_info
Expand Down Expand Up @@ -1239,8 +1239,7 @@ def get_tracer(
filterwarnings(
"ignore",
message=(
r"Call to deprecated method __init__. \(You should use "
r"InstrumentationScope\) -- Deprecated since version 1.11.1."
r"You should use InstrumentationScope. Deprecated since version 1.11.1."
),
category=DeprecationWarning,
module="opentelemetry.sdk.trace",
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from collections.abc import MutableMapping, Sequence
from typing import Optional

from deprecated import deprecated
from typing_extensions import deprecated


def ns_to_iso_str(nanoseconds):
Expand Down Expand Up @@ -93,7 +93,7 @@ def from_seq(cls, maxlen, seq):
return bounded_list


@deprecated(version="1.4.0") # type: ignore
@deprecated("Deprecated since version 1.4.0.")
class BoundedDict(MutableMapping):
"""An ordered dict with a fixed max capacity.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from json import dumps
from typing import Optional

from deprecated import deprecated
from typing_extensions import deprecated

from opentelemetry.attributes import BoundedAttributes
from opentelemetry.util.types import Attributes
Expand All @@ -29,7 +29,9 @@ class InstrumentationInfo:

__slots__ = ("_name", "_version", "_schema_url")

@deprecated(version="1.11.1", reason="You should use InstrumentationScope")
@deprecated(
"You should use InstrumentationScope. Deprecated since version 1.11.1."
)
def __init__(
self,
name: str,
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-sdk/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
asgiref==3.7.2
Deprecated==1.2.14
flaky==3.7.0
importlib-metadata==6.11.0
iniconfig==2.0.0
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-semantic-conventions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [

dependencies = [
"opentelemetry-api == 1.34.0.dev",
"Deprecated >= 1.2.6",
"typing-extensions >= 4.5.0",
]

[project.urls]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from enum import Enum
from typing import Final

from deprecated import deprecated
from typing_extensions import deprecated

CONTAINER_COMMAND: Final = "container.command"
"""
Expand Down Expand Up @@ -102,8 +102,8 @@


@deprecated(
reason="The attribute container.cpu.state is deprecated - Replaced by `cpu.mode`"
) # type: ignore
"The attribute container.cpu.state is deprecated - Replaced by `cpu.mode`"
)
class ContainerCpuStateValues(Enum):
USER = "user"
"""When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode (Windows)."""
Expand Down
Loading