Skip to content

Instantly share code, notes, and snippets.

@chrimaho
Created July 13, 2021 12:39
Show Gist options
  • Save chrimaho/6930b1f578c4997f2f58dc6f4a11edd6 to your computer and use it in GitHub Desktop.
Save chrimaho/6930b1f578c4997f2f58dc6f4a11edd6 to your computer and use it in GitHub Desktop.
Python Snippet Extended. Part of: www.github.com/chrimaho/code-snippets
{
"Function": {
"scope": "python",
"prefix": ["fun","def"],
"description": "Insert new function.",
"body":
[ "def ${1:function_name}(${2:param_1_name}:${3:param_1_type}=${4:param_1_default}, ${5:param_2_name}:${6:param_2_type}=${7:param_2_default}):"
, " '''"
, " # ${1:function_name}()"
, " "
, " ${8:Function summary}."
, " "
, " ### Args:"
, " ${2:param_1_name}(`${3:param_1_type}`${9:, optional}): ${10:param_1_description}. Defaults to `${4:param_1_default}`."
, " ${5:param_2_name}(`${6:param_2_type}`${11:, optional}): ${12:param_2_description}. Defaults to `${7:param_2_default}`."
, " "
, " ### Raises:"
, " `AssertionError`: If any of the parameter types or attributes are incorrect."
, " "
, " ### Returns:"
, " `${13:[return_type]}`: ${14:Return description}."
, " '''"
, " "
, " # Assertions"
, " assert isinstance(${2:param_1_name}, ${3:param_1_type})"
, " assert isinstance(${5:param_2_name}, ${6:param_2_type})"
, " "
, " # Do Work"
, " ${15:#Here}"
, " "
, " # Return"
, " return None"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment