Visual Studio Code Automatically adds useless code

Question:

enter code hereI recently switched to VSC, installed python, pylance plugins. Everything seemed to be working fine, but when I started working with django, vsc started automatically when selecting an option in views.py CBV including Optional: str etc, for example context_object_name: Optional[str]

Here I click Enter

And then it automatically adds

I don’t want to remove hints in the code and automatic addition, but I also don’t want him to add unnecessary

Asked By: fastbloodjke

||

Answers:

This is a new feature named Inlay Type Hints of Python extension in July update.

You can add the following line to your setting.json t o turn it off:

  "python.analysis.inlayHints.functionReturnTypes": false,
  "python.analysis.inlayHints.variableTypes": false,
Answered By: MingJie-MSFT