Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion redisvl/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import json
from enum import Enum
from functools import wraps
Expand Down Expand Up @@ -76,7 +77,7 @@ def deprecated_argument(argument: str, replacement: Optional[str] = None) -> Cal
def wrapper(func):
@wraps(func)
def inner(*args, **kwargs):
argument_names = func.__code__.co_varnames
argument_names = list(inspect.signature(func).parameters.keys())

if argument in argument_names:
warn(message, DeprecationWarning, stacklevel=2)
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
import numpy as np
import pytest

Expand Down Expand Up @@ -237,3 +238,15 @@ async def test_func(dtype=None, vectorizer=None):
with pytest.warns(DeprecationWarning):
result = await test_func(dtype="float32")
assert result == 1

async def test_ignores_local_variable(self):
@deprecated_argument("dtype")
async def test_func(vectorizer=None):
# The presence of this variable should not trigger a warning
dtype = "float32"
return 1

# This will raise an error if any warning is emitted
with warnings.catch_warnings():
warnings.simplefilter("error")
await test_func()