Probably some mistake in `class` snippet
Hi,
class snippet is not working correctly.
Expression from here is such complicated that I will not try to understand it :) but it's not working correctly. There's a problem with this second arg. It's not where it should be.
I've added PR solving that issue.
Hi @piotrgredowski
The snippet is working fine, you just need to use its auto-completion feature (the reason why its code is complicated ^^)
As shown in the video, using the tab key, you can scroll through the class definition parts and modify them. If you modify the args of the __init__ function, they will automatically be updated.
If you don't need any arguments, just remove arg in the function definition, press tab and the second arg will be removed. (As shown in the second example of the video.)
Hope this helps !
PS: If you experience problems with the auto-formatting of certain snippets, make sure you have the option editor.tabCompletion set on onlySnippets or on.
https://user-images.githubusercontent.com/60932251/182392271-ce37dec4-f1b2-474b-a028-6dc34a8f1f8b.mp4
Hi!
The class snippet doesn't allow us to write the type of the argument and we receive generated code that requires correction:
I suggest considering a small change that solves this problem for me:
"Class": {
"prefix": "class",
"body": [
"class ${1:ClassName}(${2:object}):",
"\t\"\"\"${3:docstring for $1.}\"\"\"\n",
"\tdef __init__(self, ${4:arg}) -> None:",
"\t\t\"\"\"${5:Constructor.}\"\"\"",
"\t\t${6:super($1, self).__init__()}",
"\t\t${4/\\s*([^,:=]+)([^,=]+)?(?:=[^,]+)?(,\\s*|)/self.$1$2 = $1${3:+\n\t\t}/g}",
"\t\t$0"
],
"description": 'Code snippet for a class definition.'
}
Looking good !