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
{{ message }}
Repository navigation
use an environment variable to select port in launch.json #18841
Similar to microsoft/vscode-java-debug#962 I would to like use an environment variable DEBUG_PORT to set the port on which the python debugger is listening.
Now it does not seem possible because the port variable in launch.json needs to be a number. If I try setting an env variable, as in the code below, I get the following error:
}
"name": "Py listen",
"type": "python",
"request": "attach",
"listen": {
"host": "localhost",
"port": "${env:DEBUG_PORT}"
}
We don't support it currently, but it would be a simple change. In fact, I think debugpy might as well support strings for all scalar properties, to enable substitutions everywhere.
Awesome! We have a central place where type checking & conversions are performed on JSON being parsed; the code that does the actual parsing then calls into that while specifying the types it expects to receive, and various other constraints (e.g. optional or not).
I think it would be the best to tweak the type checker for numbers to allow (convertible) string values - and automatically convert them to the corresponding number before returning. This way we also get support for e.g. 64-bit integers. The relevant code is here:
It just needs a branch for when validation without conversion fails, and one of the items in classinfo is a subtype of numbers.Number. This should cover your specific case, but it would also be nice to do the same for bool, on the oft chance that somebody might need to specify them via env vars also.
Activity
karthiknadig commentedon Apr 5, 2022
Pavel Minaev (@int19h)
debugpysupports string for port numbers right?giaco5988 commentedon Apr 11, 2022
Hi there, any news about this? Thank you
giaco5988 commentedon Apr 25, 2022
Hi Pavel Minaev (@int19h) Karthik Nadig (@karthiknadig) , is it possible to know if this is currently supported? Thank you for your time
int19h commentedon Apr 25, 2022
We don't support it currently, but it would be a simple change. In fact, I think debugpy might as well support strings for all scalar properties, to enable substitutions everywhere.
giaco5988 commentedon Apr 26, 2022
If you point me to the right part of the code, I could submit a PR. Best
int19h commentedon Apr 26, 2022
Awesome! We have a central place where type checking & conversions are performed on JSON being parsed; the code that does the actual parsing then calls into that while specifying the types it expects to receive, and various other constraints (e.g. optional or not).
I think it would be the best to tweak the type checker for numbers to allow (convertible) string values - and automatically convert them to the corresponding number before returning. This way we also get support for e.g. 64-bit integers. The relevant code is here:
https://github.com/microsoft/debugpy/blob/eaadb6c681d5375dae26093b93d239c019f0d2bc/src/debugpy/common/json.py#L106-L112
It just needs a branch for when validation without conversion fails, and one of the items in
classinfois a subtype ofnumbers.Number. This should cover your specific case, but it would also be nice to do the same forbool, on the oft chance that somebody might need to specify them via env vars also.giaco5988 commentedon May 19, 2022
Solved in microsoft/debugpy#921