svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
477 stars 31 forks source link

Correct way to pass `:args` for debugpy #7

Closed haditim closed 1 year ago

haditim commented 1 year ago

Hello and thanks a lot for the awesome package. I am trying to debug a (python) streamlit app with debugpy. The launch.json way is detailed in here https://slashgordon.github.io/post/debug_streamlit_in_vscode/. I do something similar, namely:

  (add-to-list 'dape-configs
               '(streamlit
                 modes (python-ts-mode python-mode)
                 command "python3"
                 command-args ("-m" "debugpy.adapter")
                 :type "executable"
                 :request "launch"
                 :module "streamlit"
                 :cwd dape-cwd-fn
                 :args ("run" "/home/test/streamlit_test.py")
                 ))

But I get the error Wrong type argument: symbolp, "run". Any idea what I do wrong? Doing :args("run" "/home/test/streamlit_test.py")` also does not help. Any idea what I do wrong?

Thanks again

svaante commented 1 year ago

Hi, thanks for your ticket.

TLDR: Should be :args ["run" "/home/test/streamlit_test.py"]

Made me realize that allowing lists as values for modes and command-args was stupid.

How it works is that keywords (symbols that start with :) follows other rules then symbols. Keywords are serialized to json before being sent to the adapter and so :args are being interpreted as an object. But object keys needs to be keywords so that why you are getting the error, added better errors atleast to mitigate the problem.

haditim commented 1 year ago

Thanks a lot for the reply. It works perfectly. I ended up using :args ["run" dape-find-file-buffer-default] to make it interactive.