Skip to content

Commit 6e5e02b

Browse files
authored
Remove the names and config fields deprecated in 1.x (#367)
1 parent b0e6fba commit 6e5e02b

15 files changed

Lines changed: 82 additions & 283 deletions

‎CONTEXT.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ A *bootstrapper* is ready when its framework package is importable: `is_ready()`
3737
`__init__`, raising `BootstrapperNotReadyError` when false. It is about the environment, never about
3838
the config, and it is a different question from whether an instrument is **configured**.
3939
_Avoid_: configured, for this sense. The attribute names follow the split: a bootstrapper carries
40-
`not_ready_message`, an instrument carries `not_configured_reason`. An instrument written against
41-
the old `not_ready_message` still works until 2.0: `BaseInstrument.__init_subclass__` forwards it
42-
and emits a `DeprecationWarning`.
40+
`not_ready_message`, an instrument carries `not_configured_reason`.
4341

4442
**Skipped**:
4543
An instrument the bootstrapper decided not to instantiate. Two paths, deliberately different

‎lite_bootstrap/__init__.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import typing
2-
31
from lite_bootstrap.bootstrappers.fastapi_bootstrapper import FastAPIBootstrapper, FastAPIConfig
42
from lite_bootstrap.bootstrappers.fastmcp_bootstrapper import FastMcpBootstrapper, FastMcpConfig
53
from lite_bootstrap.bootstrappers.faststream_bootstrapper import FastStreamBootstrapper, FastStreamConfig
@@ -13,14 +11,9 @@
1311
LiteBootstrapError,
1412
TeardownError,
1513
)
16-
from lite_bootstrap.helpers.warn import deprecated_module_getattr
1714
from lite_bootstrap.instruments.pyroscope_instrument import PyroscopeConfig, PyroscopeInstrument
1815

1916

20-
if typing.TYPE_CHECKING:
21-
from lite_bootstrap.bootstrappers.free_bootstrapper import FreeBootstrapperConfig as FreeBootstrapperConfig
22-
23-
2417
__all__ = [
2518
"BootstrapperNotReadyError",
2619
"ConfigurationError",
@@ -41,6 +34,3 @@
4134
"PyroscopeInstrument",
4235
"TeardownError",
4336
]
44-
45-
46-
__getattr__ = deprecated_module_getattr(__name__, {"FreeBootstrapperConfig": (FreeConfig, "FreeConfig")})

‎lite_bootstrap/bootstrappers/fastapi_bootstrapper.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,6 @@ class FastAPIConfig(
8080
"starlette": "StarletteIntegration",
8181
"fastapi": "FastApiIntegration",
8282
}
83-
# Deprecated names, removed in 2.0.
84-
_renamed_fields: typing.ClassVar[Mapping[str, str]] = {
85-
"prometheus_instrumentator_params": "prometheus_instrumentator_additional_params",
86-
"prometheus_instrument_params": "prometheus_instrument_additional_params",
87-
"prometheus_expose_params": "prometheus_expose_additional_params",
88-
"fastapi_logging_middleware_enabled": "logging_access_log_enabled",
89-
}
90-
prometheus_instrumentator_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
91-
default=UNSET, repr=False, compare=False
92-
)
93-
prometheus_instrument_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
94-
default=UNSET, repr=False, compare=False
95-
)
96-
prometheus_expose_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
97-
default=UNSET, repr=False, compare=False
98-
)
99-
fastapi_logging_middleware_enabled: bool | UnsetType = dataclasses.field(default=UNSET, repr=False, compare=False)
10083

10184
def __post_init__(self) -> None:
10285
# @dataclass(slots=True) replaces the class object, breaking bare super().

‎lite_bootstrap/bootstrappers/fastmcp_bootstrapper.py‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
disable_sentry_integrations,
2121
warn_about_sentry_integrations_installed_earlier,
2222
)
23-
from lite_bootstrap.types import UNSET, UnsetType
2423

2524

2625
if import_checker.is_fastmcp_installed:
@@ -214,19 +213,6 @@ class FastMcpConfig(
214213
prometheus_instrumentator_additional_params: dict[str, typing.Any] = dataclasses.field(default_factory=dict)
215214
prometheus_instrument_additional_params: dict[str, typing.Any] = dataclasses.field(default_factory=dict)
216215
_sentry_lean_replaced_integrations: typing.ClassVar[Mapping[str, str]] = {"starlette": "StarletteIntegration"}
217-
# Deprecated names, removed in 2.0.
218-
_renamed_fields: typing.ClassVar[Mapping[str, str]] = {
219-
"fastmcp_logging_middleware_enabled": "logging_access_log_enabled",
220-
"prometheus_instrumentator_params": "prometheus_instrumentator_additional_params",
221-
"prometheus_instrument_params": "prometheus_instrument_additional_params",
222-
}
223-
fastmcp_logging_middleware_enabled: bool | UnsetType = dataclasses.field(default=UNSET, repr=False, compare=False)
224-
prometheus_instrumentator_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
225-
default=UNSET, repr=False, compare=False
226-
)
227-
prometheus_instrument_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
228-
default=UNSET, repr=False, compare=False
229-
)
230216

231217

232218
@dataclasses.dataclass(kw_only=True)

‎lite_bootstrap/bootstrappers/free_bootstrapper.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import typing
33

44
from lite_bootstrap.bootstrappers.base import BaseBootstrapper
5-
from lite_bootstrap.helpers.warn import deprecated_module_getattr
65
from lite_bootstrap.instruments.logging_instrument import LoggingConfig, LoggingInstrument
76
from lite_bootstrap.instruments.opentelemetry_instrument import OpenTelemetryConfig, OpenTelemetryInstrument
87
from lite_bootstrap.instruments.pyroscope_instrument import PyroscopeConfig, PyroscopeInstrument
@@ -33,9 +32,3 @@ def __init__(self, bootstrap_config: FreeConfig) -> None:
3332

3433
def _prepare_application(self) -> None:
3534
return None
36-
37-
38-
if typing.TYPE_CHECKING:
39-
FreeBootstrapperConfig = FreeConfig
40-
41-
__getattr__ = deprecated_module_getattr(__name__, {"FreeBootstrapperConfig": (FreeConfig, "FreeConfig")})

‎lite_bootstrap/bootstrappers/litestar_bootstrapper.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
warn_about_sentry_integrations_installed_earlier,
2929
)
3030
from lite_bootstrap.instruments.swagger_instrument import SwaggerConfig, SwaggerInstrument
31-
from lite_bootstrap.types import UNSET, UnsetType
3231

3332

3433
if typing.TYPE_CHECKING:
@@ -262,16 +261,7 @@ class LitestarConfig(
262261
# Bounds path-label cardinality (Litestar defaults False -> raw URLs leak memory). See litestar#4891.
263262
prometheus_group_path: bool = True
264263
swagger_additional_params: dict[str, typing.Any] = dataclasses.field(default_factory=dict)
265-
# Deprecated names, removed in 2.0.
266264
_sentry_lean_replaced_integrations: typing.ClassVar[Mapping[str, str]] = {"litestar": "LitestarIntegration"}
267-
_renamed_fields: typing.ClassVar[Mapping[str, str]] = {
268-
"litestar_logging_middleware_enabled": "logging_access_log_enabled",
269-
"swagger_extra_params": "swagger_additional_params",
270-
}
271-
litestar_logging_middleware_enabled: bool | UnsetType = dataclasses.field(default=UNSET, repr=False, compare=False)
272-
swagger_extra_params: dict[str, typing.Any] | UnsetType = dataclasses.field(
273-
default=UNSET, repr=False, compare=False
274-
)
275265

276266
def __post_init__(self) -> None:
277267
# @dataclass(slots=True) replaces the class object, breaking bare super().

‎lite_bootstrap/helpers/warn.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
_DATACLASS_GENERATED_INIT: typing.Final = "<string>"
88
_INTERNAL_MODULES: typing.Final = frozenset({__name__.split(".")[0], "dataclasses"})
9+
NEXT_MAJOR_VERSION: typing.Final = "3.0"
910

1011

1112
def _is_internal_frame(frame: types.FrameType) -> bool:
@@ -52,7 +53,7 @@ def __getattr__(name: str) -> object: # noqa: N807
5253
target, replacement = aliases[name]
5354
advice = f"use {replacement} instead" if replacement else "nothing replaces it"
5455
warn_at_caller(
55-
f"{name} is deprecated and will be removed in lite-bootstrap 2.0; {advice}.",
56+
f"{name} is deprecated and will be removed in lite-bootstrap {NEXT_MAJOR_VERSION}; {advice}.",
5657
category=DeprecationWarning,
5758
)
5859
return target

‎lite_bootstrap/instruments/base.py‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import Mapping
44

55
from lite_bootstrap.exceptions import ConfigurationError
6-
from lite_bootstrap.helpers.warn import warn_at_caller
6+
from lite_bootstrap.helpers.warn import NEXT_MAJOR_VERSION, warn_at_caller
77
from lite_bootstrap.types import UNSET, UnsetType
88

99

@@ -40,7 +40,8 @@ def __post_init__(self) -> None:
4040
msg = f"{old_name} and {new_name} are both set; {old_name} is deprecated, set only {new_name}."
4141
raise ConfigurationError(msg)
4242
warn_at_caller(
43-
f"{old_name} is deprecated and will be removed in lite-bootstrap 2.0; use {new_name} instead.",
43+
f"{old_name} is deprecated and will be removed in lite-bootstrap {NEXT_MAJOR_VERSION}; "
44+
f"use {new_name} instead.",
4445
category=DeprecationWarning,
4546
)
4647
object.__setattr__(self, new_name, old_value)
@@ -63,31 +64,12 @@ def from_object(cls, obj: object) -> typing.Self:
6364
ConfigT = typing.TypeVar("ConfigT", bound=BaseConfig)
6465

6566

66-
# Legacy name -> current name; __init_subclass__ forwards an out-of-tree instrument's old spelling.
67-
_RENAMED_ATTRIBUTES: typing.Final = {
68-
"not_ready_message": "not_configured_reason",
69-
"check_dependencies": "dependencies_installed",
70-
}
71-
72-
7367
@dataclasses.dataclass(kw_only=True, slots=True)
7468
class BaseInstrument(typing.Generic[ConfigT]):
7569
bootstrap_config: ConfigT
7670
not_configured_reason = ""
7771
missing_dependency_message = ""
7872

79-
def __init_subclass__(cls, **kwargs: object) -> None:
80-
# @dataclass(slots=True) replaces the class object, breaking bare super().
81-
super(BaseInstrument, cls).__init_subclass__(**kwargs)
82-
for legacy_name, current_name in _RENAMED_ATTRIBUTES.items():
83-
if legacy_name in cls.__dict__ and current_name not in cls.__dict__:
84-
warn_at_caller(
85-
f"{cls.__name__}.{legacy_name} is deprecated and will be removed in lite-bootstrap 2.0; "
86-
f"use {current_name} instead.",
87-
category=DeprecationWarning,
88-
)
89-
setattr(cls, current_name, cls.__dict__[legacy_name])
90-
9173
def bootstrap(self) -> None: ...
9274

9375
def teardown(self) -> None: ...

‎lite_bootstrap/instruments/logging_factory.py‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,12 @@
66
import typing
77

88
from lite_bootstrap import import_checker
9-
from lite_bootstrap.helpers.warn import deprecated_module_getattr
109

1110

1211
if import_checker.is_orjson_installed:
1312
import orjson
1413

1514

16-
_ScopeType = typing.MutableMapping[str, typing.Any]
17-
18-
19-
class _AddressProtocol(typing.Protocol):
20-
host: str
21-
port: int
22-
23-
24-
class _RequestProtocol(typing.Protocol):
25-
client: _AddressProtocol
26-
scope: _ScopeType
27-
method: str
28-
29-
30-
if typing.TYPE_CHECKING:
31-
ScopeType = _ScopeType
32-
AddressProtocol = _AddressProtocol
33-
RequestProtocol = _RequestProtocol
34-
35-
_DEPRECATED_PROTOCOLS: typing.Final = {
36-
"AddressProtocol": (_AddressProtocol, None),
37-
"RequestProtocol": (_RequestProtocol, None),
38-
"ScopeType": (_ScopeType, None),
39-
}
40-
41-
4215
@dataclasses.dataclass(kw_only=True, slots=True, frozen=True)
4316
class _MemoryLoggerFactoryConfig:
4417
logging_buffer_capacity: int
@@ -163,6 +136,3 @@ def close_handlers(self) -> None:
163136
target.close()
164137
self._created_handlers.clear()
165138
self._leveled_loggers.clear()
166-
167-
168-
__getattr__ = deprecated_module_getattr(__name__, _DEPRECATED_PROTOCOLS)

‎lite_bootstrap/instruments/logging_instrument.py‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55

66
from lite_bootstrap import import_checker
77
from lite_bootstrap.exceptions import collect_teardown_errors
8-
from lite_bootstrap.helpers.warn import deprecated_module_getattr
98
from lite_bootstrap.instruments.base import BaseConfig, BaseInstrument
109
from lite_bootstrap.instruments.logging_factory import (
11-
_DEPRECATED_PROTOCOLS,
12-
_AddressProtocol,
1310
_MemoryLoggerFactoryConfig,
14-
_RequestProtocol,
15-
_ScopeType,
1611
_serialize_log_to_string,
1712
)
1813

@@ -239,11 +234,3 @@ def teardown(self) -> None:
239234
self._logger_factory.close_handlers()
240235
finally:
241236
self._logger_factory = None
242-
243-
244-
if typing.TYPE_CHECKING:
245-
AddressProtocol = _AddressProtocol
246-
RequestProtocol = _RequestProtocol
247-
ScopeType = _ScopeType
248-
249-
__getattr__ = deprecated_module_getattr(__name__, _DEPRECATED_PROTOCOLS)

0 commit comments

Comments
 (0)