Created
May 29, 2020 12:04
-
-
Save chivandikwa/20d1319e83ef46002742687cf90995d7 to your computer and use it in GitHub Desktop.
Pycharm live templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
$END$ | |
except Exception as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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