Skip to content

Commit 62f3156

Browse files
author
NIK-TIGER-BILL
committed
fix(deps): remove unmaintained deprecation package, inline stdlib replacement
The `deprecation` package (>=2.1.0,<3.0.0) has had no release since 2019 and is flagged as a security / maintenance risk by dependency scanners. The package was only used in one file (`weaviate/collections/batch/client.py`) to add docstring notes and emit `DeprecationWarning` at call time. This PR removes the external dependency and replaces it with an equivalent `docstring_deprecated` helper implemented entirely with stdlib (`functools`, `warnings`). The public behaviour is unchanged: * The function docstring gets a `.. deprecated::` RST prefix. * Calling the function emits a :class:`DeprecationWarning`. The `typing_extensions.deprecated` import (already present) is kept because it provides static analysis / IDE warnings via the `__deprecated__` attribute. Fixes #1998 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
1 parent bced996 commit 62f3156

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ install_requires =
4040
pydantic>=2.12.0,<3.0.0
4141
grpcio>=1.59.5,<1.80.0
4242
protobuf>=4.21.6,<7.0.0
43-
deprecation>=2.1.0,<3.0.0
4443
python_requires = >=3.10
4544

4645
[options.extras_require]

weaviate/collections/batch/client.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
11
from concurrent.futures import ThreadPoolExecutor
22
from typing import TYPE_CHECKING, Optional, Type, Union
33

4-
from deprecation import deprecated as docstring_deprecated
4+
import functools
5+
import warnings as _warnings
6+
from typing import Callable
7+
58
from typing_extensions import deprecated as typing_deprecated
69

10+
11+
def docstring_deprecated(details: str = "", deprecated_in: str = "", **_kwargs: object) -> Callable:
12+
"""Replacement for ``deprecation.deprecated`` that uses only stdlib.
13+
14+
The ``deprecation`` package has not been maintained since 2019 and is
15+
flagged as a security risk by several dependency scanners. This
16+
in-module helper replicates the behaviour we need:
17+
18+
1. Prepend a ``.. deprecated::`` note to the docstring.
19+
2. Emit a :class:`DeprecationWarning` at call time.
20+
"""
21+
22+
def decorator(func: Callable) -> Callable:
23+
docstring = func.__doc__ or ""
24+
note = f".. deprecated:: {deprecated_in}\n {details}\n\n" if deprecated_in else ""
25+
func.__doc__ = note + docstring
26+
27+
@functools.wraps(func)
28+
def wrapper(*args: object, **kwargs: object) -> object:
29+
_warnings.warn(
30+
f"{func.__qualname__} is deprecated since {deprecated_in}. {details}",
31+
DeprecationWarning,
32+
stacklevel=2,
33+
)
34+
return func(*args, **kwargs)
35+
36+
wrapper.__doc__ = func.__doc__
37+
return wrapper
38+
39+
return decorator
40+
741
from weaviate.collections.batch.async_ import _BatchBaseAsync
842
from weaviate.collections.batch.base import (
943
_BatchBase,

0 commit comments

Comments
 (0)