Skip to content

Commit 7e3bb5d

Browse files
Alan Ninan Thomasbrettcannon
andauthored
Adding docstrings to snippets (#13343)
* Added docstrings to snippets * added a news entry file * Sorry! I a typo * Revert "Sorry! I a typo" This reverts commit cbbff6a. * Revert "added a news entry file" This reverts commit 6edf889. * Revert "Added docstrings to snippets" This reverts commit 3bdcdd1. * Hopefully, it fixed the whitespace issues * Update snippets/python.json Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Brett Cannon <brett@python.org>
1 parent 9ef8a58 commit 7e3bb5d

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

news/1 Enhancements/5578.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Docstrings are added to `class` and `def` snippets (thanks [alannt777](https://github.com/alannt777/))

snippets/python.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,27 @@
9494
},
9595
"def": {
9696
"prefix": "def",
97-
"body": ["def ${1:funcname}(${2:parameter_list}):", "\t${3:pass}"],
97+
"body": ["def ${1:funcname}(${2:parameter_list}):", "\t\"\"\"", "\t${3:docstring}", "\t\"\"\"","\t${4:pass}"],
9898
"description": "Code snippet for a function definition"
9999
},
100100
"def(class method)": {
101101
"prefix": "def(class method)",
102-
"body": ["def ${1:funcname}(self, ${2:parameter_list}):", "\t${3:pass}"],
102+
"body": ["def ${1:funcname}(self, ${2:parameter_list}):", "\t\"\"\"", "\t${3:docstring}", "\t\"\"\"", "\t${4:pass}"],
103103
"description": "Code snippet for a class method"
104104
},
105105
"def(static class method)": {
106106
"prefix": "def(static class method)",
107-
"body": ["@staticmethod", "def ${1:funcname}(${2:parameter_list}):", "\t${3:pass}"],
107+
"body": ["@staticmethod", "def ${1:funcname}(${2:parameter_list}):", "\t\"\"\"", "\t${3:docstring}", "\t\"\"\"", "\t${4:pass}"],
108108
"description": "Code snippet for a static class method"
109109
},
110110
"def(abstract class method)": {
111111
"prefix": "def(abstract class method)",
112-
"body": ["def ${1:funcname}(self, ${2:parameter_list}):", "\traise NotImplementedError"],
112+
"body": ["def ${1:funcname}(self, ${2:parameter_list}):", "\t\"\"\"", "\t${3:docstring}", "\t\"\"\"", "\traise NotImplementedError"],
113113
"description": "Code snippet for an abstract class method"
114114
},
115115
"class": {
116116
"prefix": "class",
117-
"body": ["class ${1:classname}(${2:object}):", "\t${3:pass}"],
117+
"body": ["class ${1:classname}(${2:object}):", "\t\"\"\"", "\t${3:docstring}", "\t\"\"\"", "\t${4:pass}"],
118118
"description": "Code snippet for a class definition"
119119
},
120120
"lambda": {

0 commit comments

Comments
 (0)