Vscode for python ide配置
2020-12-13 13:59
标签:str tac scripts har 若是 pre 参数 date 长度 快捷键: ctrl+shift+2, 或在函数定义后输入: """ 修改autoDocstring.docstringFormat栏即可 修改autoDocstring.customTemplatePath为你新建的.mustache文件的地址 (详细关键字配置请查看插件介绍) (以black为例) (以pylint为例) Vscode for python ide配置 标签:str tac scripts har 若是 pre 参数 date 长度 原文地址:https://www.cnblogs.com/TesterH2o/p/11548086.html1.文件头添加
"HEADER":{
"prefix": "header",
"body": [
"# -*- encoding: utf-8 -*-",
"",
"# @File : $TM_FILENAME",
"# @Time : $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"# @Author : H2o ",
"# @Version : 1.0",
"# @Contact : 515430193@qq.com",
"",
"",
""
],
}
2.进入设置界面
3.为不同的项目配置python虚拟环境
4.自动函数生成注释模板
4.1.切换注释生成模板
4.2.自定义模板样式
个人使用google注释模板,.mustache文件内容如下:{{! Google Docstring Template }}
{{summaryPlaceholder}}
{{extendedSummaryPlaceholder}}
{{#parametersExist}}
Args:
{{#args}}
{{var}} ({{typePlaceholder}}): {{descriptionPlaceholder}}
{{/args}}
{{#kwargs}}
{{var}} ({{typePlaceholder}}, optional): {{descriptionPlaceholder}}. Defaults to {{&default}}.
{{/kwargs}}
{{/parametersExist}}
{{#exceptionsExist}}
Raises:
{{#exceptions}}
{{type}}: {{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}
{{#returnsExist}}
Returns:
{{#returns}}
{{typePlaceholder}}: {{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}
5.配置代码格式化工具
例如: C:\Program Files\Python36\Scripts\black.exe
(black每行允许的字符长度为88)6.配置代码静态检查工具
7.插件安装
项目
说明
是否必需安装
Python
是
vscode-icons
美化文件图标
否
Better Comments
美化行注释
否
Chinese (Simplified) Language Pack
for Visual Studio Code中文汉化包
否
autoDocstring
函数注释模板生成
否
8.json文件内容
8.1 用户json文件
{
"files.autoSave": "afterDelay",
"editor.renderWhitespace": "all",
"editor.wordWrap": "wordWrapColumn",
"workbench.startupEditor": "newUntitledFile",
"workbench.iconTheme": "vscode-icons",
"workbench.colorTheme": "Bluloco Light",
"editor.fontFamily": "InputMono, Consolas, 'Courier New', monospace",
"editor.fontSize": 15,
"editor.lineHeight": 27,
"python.formatting.provider": "black",
"python.formatting.blackPath": "C:\\Program Files\\Python36\\Scripts\\black.exe",
"python.formatting.blackArgs": [
"--line-length=80"
],
"editor.renderControlCharacters": false,
"autoDocstring.customTemplatePath": "C:\\Program Files\\Microsoft VS Code\\data\\google.mustache"
}
8.2 工作区json文件
{
"python.pythonPath": "D:\\ENV\\Testtools\\Scripts\\python.exe",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
}