Skip to content

Commit 4c39bd8

Browse files
committed
Move decorator to separate private helper module to prevent circular dependencies
1 parent 48dadeb commit 4c39bd8

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

harp/__init__.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
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
64

75

86
__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

harp/_helpers.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import warnings
2+
import functools
3+
4+
5+
def deprecated(message):
6+
# This decorator is only available from the stdlib warnings module in Python 3.13
7+
# Making it available here for compatibility with older versions
8+
def decorator(func):
9+
@functools.wraps(func)
10+
def wrapper(*args, **kwargs):
11+
warnings.warn(
12+
f"Call to deprecated function {func.__name__}: {message}",
13+
category=DeprecationWarning,
14+
stacklevel=1,
15+
)
16+
return func(*args, **kwargs)
17+
18+
return wrapper
19+
20+
return decorator

harp/reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, BinaryIO, Callable, Iterable, Mapping, Optional, Protocol, Union
1010

1111
import requests
12-
from harp import deprecated
12+
from harp._helpers import deprecated
1313
from numpy import dtype
1414
from pandas import DataFrame, Series
1515
from pandas._typing import Axes

0 commit comments

Comments
 (0)