vscode-python: Snippets do not work for Python

Environment data

  • VS Code version: 1.52.1
  • Extension version (available under the Extensions sidebar): v2021.1.502429796
  • OS and version: macOS 11.1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.1, homebrew
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: Jedi

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Code Snippets do not work for Python. This has worked for me before.

Actual behaviour

For example, if I type the def keyword, code normally snows a popup to insert a snippet which contains a basic definition of a Python function. The snippet for the function no longer works. The def keyword is entered and the snippet is not created.

Screen Shot 2021-01-24 at 14 19 48

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

Here is an example with the for keyword. Normally, I would see a popup for several types of for statements. This is no longer working.

Screen Shot 2021-01-24 at 16 48 39

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

No text output is displayed.

Screen Shot 2021-01-25 at 06 23 43

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Any idea on how to downgrade to the previous version?

You can install any previous version like this:

version downgrading

Hey folks, sorry for the frustration! The main feedback we got from our snippets is that they’re actually confusing and overwhelming, especially to beginners and students. We often heard they were annoying too, so we ended up removing them. I understand they can still be pretty useful though, I use custom snippets myself. If you want them back you can copy them from here, and then create snippets in VS Code (instructions can be found here: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets). Additionally, as @mikemadden42 pointed out in this comment, you can also get additional snippets through this extension: https://marketplace.visualstudio.com/items?itemName=frhtylcn.pythonsnippets. This way you can still get updates from the Python extension and keep using the snippets 😊

I’m closing this issue as we don’t intend to bring back the snippets for now, at least not until we have a mechanism to make it play nice with Pylance in VS Code.

Aren’t snippets supposed to be exactly what the name describes? Just snippets of code to reduce manual typing / copy-pasting from somewhere / avoid looking up exact syntax.

FWIW, I think they were incredibly useful just as they were and we’ve lost something by disabling the built-in ones completely.

Great find @hssandriss !

I’m not sure on the rationale for removing the snippets. I find this feature very useful.

I did find an alternative collection of snippets for Python & vscode. Until this issue is resolved, I’m using these new snippets with code. https://marketplace.visualstudio.com/items?itemName=frhtylcn.pythonsnippets

Here’s the github link: https://github.com/ylcnfrht/vscode-python-snippet-pack

@s2t2 your best option is to copy the old snippets and make them your own. If you set up Settings Sync in VS Code it will save them to the cloud and so you don’t have to worry about losing them in the future.

But downgrading isn’t really a solution as we are not bringing the snippets back.