Skip to content

Commit 13a6862

Browse files
committed
Add deprecated decorator
1 parent 828cd3b commit 13a6862

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

harp/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
from harp.io import REFERENCE_EPOCH, MessageType, read
22
from harp.reader import create_reader
33
from harp.schema import read_schema
4+
import warnings
5+
import functools
6+
47

58
__all__ = ["REFERENCE_EPOCH", "MessageType", "read", "create_reader", "read_schema"]
9+
10+
11+
def deprecated(message):
12+
# This decorator is only available from the stdlib warnings module in Python 3.13
13+
# Making it available here for compatibility with older versions
14+
def decorator(func):
15+
@functools.wraps(func)
16+
def wrapper(*args, **kwargs):
17+
warnings.warn(
18+
f"Call to deprecated function {func.__name__}: {message}",
19+
category=DeprecationWarning,
20+
stacklevel=1,
21+
)
22+
return func(*args, **kwargs)
23+
24+
return wrapper
25+
26+
return decorator

0 commit comments

Comments
 (0)