Skip to content

Instantly share code, notes, and snippets.

@chivandikwa
Created May 29, 2020 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chivandikwa/20d1319e83ef46002742687cf90995d7 to your computer and use it in GitHub Desktop.
Save chivandikwa/20d1319e83ef46002742687cf90995d7 to your computer and use it in GitHub Desktop.
Pycharm live templates
import functools
def $NAME$(func):
@functools.wraps(func)
async def _$NAME$(*args, **kwargs):
# optionally do something before
result = await func(*args, **kwargs)
# optionally do something after
return result
return _$NAME$
import functools
from typing import Any
def $NAME$(func=None, *, param: Any):
def $NAME$_decorator(func):
@functools.wraps(func)
async def _$NAME$(*args, **kwargs):
# optionally do something before
result = await func(*args, **kwargs)
# optionally do something after
return result
return _$NAME$
if func is None:
return $NAME$_decorator
else:
return $NAME$_decorator(func)
$END$
try:
$END$
except Exception as e:
import unittest
class TestClass(unittest.TestCase):
def test_$NAME$(self):
$END$
self.assertTrue(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment