Closed
Description
When try to run code in PyCharm in Debug mode I get VarnameRetrievingError.
Code to reproduce:
import varname
abc = 5
abc_varname = varname.nameof(abc)
print(abc_varname)
Result:
E:\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 62134 --file "E:/Projects/python_projects/get_var_name.py"
Connected to pydev debugger (build 213.7172.26)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/Projects/python_projects/get_var_name.py", line 6, in <module>
abc_varname = varname.nameof(abc)
File "E:\venv\lib\site-packages\varname\core.py", line 277, in nameof
node = get_node_by_frame(frameobj, raise_exc=True)
File "E:\venv\lib\site-packages\varname\utils.py", line 141, in get_node_by_frame
raise VarnameRetrievingError(
varname.utils.VarnameRetrievingError: Couldn't retrieve the call node. This may happen if you're using some other AST magic at the same time, such as pytest, ipython, macropy, or birdseye.
python-BaseException
Process finished with exit code 1
python 3.10
varname 0.8.3
Metadata
Metadata
Assignees
Labels
No labels