aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.51k stars 436 forks source link

"Add Debug Configuration" codelens polluting python import statements #1585

Closed dferrante closed 3 years ago

dferrante commented 3 years ago

Describe the bug

Seeing a cascade of Add Debug Configuration on my file imports.

How do I make these go away? I'm not using SAM so I'd like to disable that functionality entirely

To Reproduce

Run extension on a vscode instance that doesn't have SAM installed and open a python file

Expected behavior

I want it to not show any of that around the imports

Screenshots

Screenshot-20210319131918-909x269

Desktop (please complete the following information):

OS: Linux x64 5.8.0-44-generic (Ubuntu 20.04) Visual Studio Code Extension Host Version: 1.54.3 AWS Toolkit Version: 1.21.0

Additional context

None

justinmk3 commented 3 years ago

@dferrante does this happen on every python project, or only a particular one or particular file?

vscode instance that doesn't have SAM installed

Does that mean the problem goes away if sam is on the system?

bryceitoc9 commented 3 years ago

Our criteria for codelenses in Python files are:

Out of curiosity, do these codelenses show up in any places they're supposed to, and what gets outputted into the launch.json file if one of the codelenses you showed in the screenshot is clicked?

dferrante commented 3 years ago

@justinmk3 my bad for being unclear, i have not tested it with SAM installed

@bryceitoc9 this screenshot is from a file within my (django/zappa) project, with a requirements.txt at the root of it. i see now that the "Add Debug Configuration" pops up for each import that is also a function, though not always functions even within my project (e.g. from django.urls import reverse triggers it). when the codelens is clicked, they do indeed open up my launch.json and add a aws-sam lambda invoke for this function pointed at the correct file.

i'm now realizing that this is not quite a bug but a feature request to add a switch to turn off this codelens or otherwise disable aws-toolkit-vscode from treating my whole project like its a lambda function being deployed on its own.

bryceitoc9 commented 3 years ago

We have a feature request for disabling the codelenses here: https://github.com/aws/aws-toolkit-vscode/issues/1374 (feel free to pile onto that one) , but this is definitely a bug (maybe the language server is flagging imported functions as function symbols instead of just functions declared in the file itself?). We'll keep this issue open while we investigate.

Just out of curiosity, for from django.urls import reverse, what's the entry in launch.json? Assuming it has a handler name of something like <handlerfile>.reverse?

dferrante commented 3 years ago

@bryceitoc9 ah great thanks, and yes confirmed, the handler name in launch.json is <handlerfile>.reverse.

fwiw my language server is jedi (which i believe is the default) and i have the following extensions installed:

amazonwebservices.aws-toolkit-vscode
atlassian.atlascode
aws-scripting-guy.cform
batisteo.vscode-django
bibhasdn.django-html
bibhasdn.django-snippets
bigonesystems.django
eamodio.gitlens
eg2.vscode-npm-script
formulahendry.vscode-mysql
GitLab.gitlab-workflow
kenhowardpdx.vscode-gist
LuminusDev.azureloginaws
magicstack.Chromodynamics
mechatroner.rainbow-csv
mhutchie.git-graph
ms-azuretools.vscode-docker
ms-python.python
ms-toolsai.jupyter
PsykoSoldi3r.vscode-git-flow
redhat.vscode-yaml
ryanluker.vscode-coverage-gutters
Shan.code-settings-sync
shyykoserhiy.vscode-spotify
waderyan.gitblame
ZainChen.json

thanks for your time!

bryceitoc9 commented 3 years ago

Hmm, at a bit of a loss...I can't replicate with the jedi language server and (what I'm thinking is) a simple example: image

Out of curiosity, does this flag any imports that aren't django-based? If so, it might be tied to some of the django plugins you have installed.

dferrante commented 3 years ago

@bryceitoc9 it seems to be any function, for instance: image

bryceitoc9 commented 3 years ago

Codelens toggle (also with a command to run the codelens action without clicking a codelens) here: #1681 ; feel free to give it a shot (download the artifact from the details of one of the finished packaging tests).

dferrante commented 3 years ago

@bryceitoc9 confirmed it works as expected, thank you, have a nice day!

justinmk3 commented 3 years ago

Toolkit 1.25 adds these features: