|
6 | 6 | import typing |
7 | 7 |
|
8 | 8 | from lite_bootstrap import import_checker |
| 9 | +from lite_bootstrap.helpers.warn import deprecated_module_getattr |
9 | 10 |
|
10 | 11 |
|
11 | 12 | if import_checker.is_orjson_installed: |
12 | 13 | import orjson |
13 | 14 |
|
14 | 15 |
|
15 | | -ScopeType = typing.MutableMapping[str, typing.Any] |
| 16 | +_ScopeType = typing.MutableMapping[str, typing.Any] |
16 | 17 |
|
17 | 18 |
|
18 | | -class AddressProtocol(typing.Protocol): |
| 19 | +class _AddressProtocol(typing.Protocol): |
19 | 20 | host: str |
20 | 21 | port: int |
21 | 22 |
|
22 | 23 |
|
23 | | -class RequestProtocol(typing.Protocol): |
24 | | - client: AddressProtocol |
25 | | - scope: ScopeType |
| 24 | +class _RequestProtocol(typing.Protocol): |
| 25 | + client: _AddressProtocol |
| 26 | + scope: _ScopeType |
26 | 27 | method: str |
27 | 28 |
|
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 | + |
29 | 42 | @dataclasses.dataclass(kw_only=True, slots=True, frozen=True) |
30 | 43 | class _MemoryLoggerFactoryConfig: |
31 | 44 | logging_buffer_capacity: int |
@@ -141,3 +154,6 @@ def close_handlers(self) -> None: |
141 | 154 | if target is not None: |
142 | 155 | target.close() |
143 | 156 | self._created_handlers.clear() |
| 157 | + |
| 158 | + |
| 159 | +__getattr__ = deprecated_module_getattr(__name__, _DEPRECATED_PROTOCOLS) |
0 commit comments