|
47 | 47 | },
|
48 | 48 | "New class": {
|
49 | 49 | "prefix": "class",
|
50 |
| - "body": "class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1.}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.arg = arg\n\t\t$0", |
| 50 | + "body": [ |
| 51 | + "class ${1:ClassName}(${2:object}):", |
| 52 | + "\t\"\"\"${3:docstring for $1.}\"\"\"", |
| 53 | + "\tdef __init__(self, ${4:arg}):", |
| 54 | + "\t\t${5:super($1, self).__init__()}", |
| 55 | + "\t\tself.$4 = $4", |
| 56 | + "\t\t$0" |
| 57 | + ], |
51 | 58 | "description" : "Code snippet for a class definition."
|
52 | 59 | },
|
| 60 | + "New dataclass": { |
| 61 | + "prefix": "classd", |
| 62 | + "body": [ |
| 63 | + "from dataclasses import dataclass\n\n", |
| 64 | + "@dataclass", |
| 65 | + "class ${1:ClassName}(${2:object}):", |
| 66 | + "\t\"\"\"${3:Docstring for $1.}\"\"\"", |
| 67 | + "\t${4:property}: ${type}", |
| 68 | + "\t$0" |
| 69 | + ], |
| 70 | + "description": "Code snippet for a dataclass definition." |
| 71 | + }, |
53 | 72 | "New method": {
|
54 | 73 | "prefix": "defs",
|
55 | 74 | "body": "def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0",
|
|
75 | 94 | "body": "def ${1:foo}():\n doc = \"${2:The $1 property.}\"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n def fdel(self):\n ${5:del self._$1}\n return locals()\n$1 = property(**$1())$0",
|
76 | 95 | "description" : ""
|
77 | 96 | },
|
| 97 | + "New enum": { |
| 98 | + "prefix": "enum", |
| 99 | + "body": [ |
| 100 | + "from enum import Enum\n\n", |
| 101 | + "class ${1:MyEnum}(Enum):", |
| 102 | + "\t\"\"\"${2:Docstring for $1.}\"\"\"", |
| 103 | + "\t${3:FIRST_ENUM} = \"some_value\"", |
| 104 | + "\t${4:SECOND_ENUM} = \"some_other_value\"", |
| 105 | + "\t$0" |
| 106 | + ], |
| 107 | + "description": "Code snippet for enum definition." |
| 108 | + }, |
78 | 109 | "if": {
|
79 | 110 | "prefix": "if",
|
80 | 111 | "body": "if ${1:condition}:\n\t${2:pass}$0",
|
|
0 commit comments