Last active
October 25, 2024 09:00
-
-
Save SebDeclercq/3c115c547f0065e05e01944038b0c0c4 to your computer and use it in GitHub Desktop.
My vscode python snippets + config
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
{ | |
"f-string": { | |
"prefix": "fs", | |
"body": "f'$0'", | |
}, | |
"print('')": { | |
"prefix": "p", | |
"body": "print('$0')" | |
}, | |
"print(f'')": { | |
"prefix": "fp", | |
"body": "print(f'$0')" | |
}, | |
"def main():": { | |
"prefix": "defmain", | |
"body": [ | |
"def main() -> None:", | |
" '''Main function'''", | |
" ${0:...}", | |
"", | |
"if __name__ == '__main__':", | |
" main()", | |
"" | |
] | |
}, | |
"async def main():": { | |
"prefix": "asyncdefmain", | |
"body": [ | |
"async def main() -> None:", | |
" '''Main function'''", | |
" ${0:...}", | |
"", | |
"if __name__ == '__main__':", | |
" asyncio.run(main())", | |
"" | |
] | |
}, | |
"def __init__():": { | |
"prefix": "definit", | |
"body": [ | |
"def __init__(self${1:, }) -> None:", | |
" '''Constructor'''", | |
" ${0:...}" | |
] | |
}, | |
"import dataclasses": { | |
"prefix": "idataclass", | |
"body": "from dataclasses import dataclass" | |
}, | |
"import monkeypatch": { | |
"prefix": "imonkey", | |
"body": "from _pytest.monkeypatch import MonkeyPatch" | |
}, | |
"import unittest.mock": { | |
"prefix": "iunitmock", | |
"body": "from unittest.mock import Mock" | |
}, | |
"from pytest_mock import MockerFixture": { | |
"prefix": "imockerfixture", | |
"body": "from pytest_mock import MockerFixture" | |
}, | |
"@pytest.fixture": { | |
"prefix": "pyfixture", | |
"body": "@pytest.fixture", | |
}, | |
"@pytest.mark.current_dev": { | |
"prefix": "pycurrent_dev", | |
"body": "@pytest.mark.current_dev" | |
}, | |
"@pytest.mark.integ": { | |
"prefix": "pyinteg", | |
"body": "@pytest.mark.integ" | |
}, | |
"@pytest.mark.asyncio": { | |
"prefix": "pyasyncio", | |
"body": "@pytest.mark.asyncio" | |
}, | |
"@pytest.mark.django_db": { | |
"prefix": "pydjangodb", | |
"body": "@pytest.mark.django_db" | |
}, | |
"@pytest.mark.django_db(transaction=True)": { | |
"prefix": "pydjangotransdb", | |
"body": "@pytest.mark.django_db(transaction=True)" | |
}, | |
"@pytest.mark.skip": { | |
"prefix": "pyskip", | |
"body": "@pytest.mark.skip" | |
}, | |
"@pytest.mark.parametrize": { | |
"prefix": "pyparam", | |
"body": "@pytest.mark.parametrize(${0:...})" | |
}, | |
"async def": { | |
"prefix": "asyncdef", | |
"body": [ | |
"async def ${1:func}(${2:params}) -> ${3:None}:", | |
" '''${4:Docstring}'''", | |
" $0" | |
] | |
}, | |
"from __future__ import annotations": { | |
"prefix": "ifuture", | |
"body": "from __future__ import annotations" | |
}, | |
"from pathlib import Path": { | |
"prefix": "ipathlib", | |
"body": "from pathlib import Path" | |
}, | |
"*args: Any, **kwargs: Any": { | |
"prefix": "args_kwargs_typed", | |
"body": "*args: Any, **kwargs: Any" | |
}, | |
"reveal_type": { | |
"prefix": "rv", | |
"body": "reveal_type($0)" | |
}, | |
"run_in_executor": { | |
"prefix": "sync_to_async", | |
"body": [ | |
"await asyncio.get_running_loop().run_in_executor(", | |
" None, functools.partial(${1:sync function}, ${2:args})", | |
")" | |
] | |
}, | |
"plotly_offline": { | |
"prefix": "plotly_offline", | |
"body": "plotly.offline.init_notebook_mode()" | |
} | |
} |
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
{ | |
"telemetry.telemetryLevel": "off", | |
"editor.bracketPairColorization.enabled": true, | |
"editor.guides.bracketPairs": "active", | |
"files.associations": { | |
"**/*.html": "html", | |
"**/templates/**/*.html": "django-html", | |
"**/requirements{/**,*}.{txt,in,lock}": "pip-requirements", | |
"*.locations": "nginx", | |
"*.site": "nginx", | |
"*.avsc": "json", | |
"*.toml": "ini", | |
}, | |
"workbench.editorAssociations": { | |
"*.ipynb": "jupyter-notebook", | |
"*.db": "sqlite-viewer.option", | |
".coverage": "sqlite-viewer.option" | |
}, | |
"notebook.cellToolbarLocation": { | |
"default": "right", | |
"jupyter-notebook": "left" | |
}, | |
"editor.multiCursorModifier": "ctrlCmd", | |
"editor.wordWrapColumn": 88, | |
"editor.rulers": [ | |
88 | |
], | |
"editor.formatOnPaste": true, | |
"editor.renderWhitespace": "none", | |
"breadcrumbs.enabled": true, | |
"editor.formatOnType": true, | |
"editor.formatOnSave": true, | |
"python.linting.lintOnSave": true, | |
"python.linting.mypyCategorySeverity.error": "Hint", | |
"python.linting.mypyCategorySeverity.note": "Hint", | |
"python.linting.mypyEnabled": true, | |
"python.formatting.provider": "black", | |
// new stuff to try | |
// "python.languageServer": "Pylance", | |
"python.analysis.autoFormatStrings": true, | |
"python.analysis.gotoDefinitionInStringLiteral": true, | |
"python.analysis.inlayHints.pytestParameters": true, | |
"python.analysis.enablePytestSupport": true, | |
"python.analysis.fixAll": [ | |
"source.unusedImports" | |
], | |
// end of new stuff | |
"git.autofetch": true, | |
"editor.fontFamily": "Consolas", | |
"editor.codeLensFontFamily": "Consolas", | |
"markdown.preview.fontSize": 18, | |
"editor.fontSize": 18, | |
"editor.minimap.enabled": false, | |
"files.defaultLanguage": "python", | |
"python.linting.flake8Args": [ | |
"--ignore=F401" | |
], | |
"explorer.confirmDragAndDrop": false, | |
"jupyter.askForKernelRestart": false, | |
"diffEditor.ignoreTrimWhitespace": false, | |
"liveshare.connectionMode": "relay", | |
"workbench.startupEditor": "none", | |
"git.openRepositoryInParentFolders": "always", | |
"[python]": { | |
"diffEditor.ignoreTrimWhitespace": false, | |
"editor.formatOnType": true, | |
"editor.wordBasedSuggestions": false | |
}, | |
"search.useIgnoreFiles": false, | |
"workbench.colorTheme": "Red", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment