You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/home/hein_f0/dev/slki-code/.venv/lib/python3.11/site-packages/varname/core.py", line 469, in argname
argument_sources = get_argument_sources(
^^^^^^^^^^^^^^^^^^^^^
File "/home/hein_f0/dev/slki-code/.venv/lib/python3.11/site-packages/varname/utils.py", line 442, in get_argument_sources
bound_args = signature.bind_partial(*arg_sources, **kwarg_sources)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/inspect.py", line 3219, in bind_partial
return self._bind(args, kwargs, partial=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/inspect.py", line 3201, in _bind
raise TypeError(
TypeError: got an unexpected keyword argument 'y'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hein_f0/dev/slki-code/test.py", line 11, in <module>
fn(x, y=6) # Error
^^^^^^^^^^
File "/home/hein_f0/dev/slki-code/test.py", line 5, in fn
print(nameof(var, frame=2))
^^^^^^^^^^^^^^^^^^^^
File "/home/hein_f0/dev/slki-code/.venv/lib/python3.11/site-packages/varname/core.py", line 333, in nameof
out = argname(
^^^^^^^^
File "/home/hein_f0/dev/slki-code/.venv/lib/python3.11/site-packages/varname/core.py", line 476, in argname
raise ImproperUseError(
varname.utils.ImproperUseError: Have you specified the right `frame` or `func`?
The signature here is the nameof function: <Signature (var: Any, *more_vars: Any, frame: int = 1, vars_only: bool = True) -> Union[str, Tuple[str, ...]]> and therefore does not take any kwarg_sources from the source function fn.
Workaround
None, as far as I know.
The text was updated successfully, but these errors were encountered:
The signature binding fails if the function contains
kwarg_sources
.Reproduce
Traceback
Problem
If I am not mistaken, the issue lies in line 442:
python-varname/varname/utils.py
Lines 431 to 442 in 1e07fce
The
signature
here is thenameof
function:<Signature (var: Any, *more_vars: Any, frame: int = 1, vars_only: bool = True) -> Union[str, Tuple[str, ...]]>
and therefore does not take anykwarg_sources
from the source functionfn
.Workaround
None, as far as I know.
The text was updated successfully, but these errors were encountered: