pycharm 使用black
The Uncompromising Code Formatter

By using Black, you agree to cede control over minutiae of hand-formatting. In return,

Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting.

You will save time and mental energy for more important matters.

PyCharm/IntelliJ IDEA增加
1、Install black.
$ pip install black
Locate your black installation folder.
On macOS / Linux / BSD:

$ which black
/usr/local/bin/black # possible location
On Windows:

$ where black
%LocalAppData%\Programs\Python\Python36-32\Scripts\black.exe # possible location
2、Open External tools in PyCharm/IntelliJ IDEA
On macOS:

PyCharm -> Preferences -> Tools -> External Tools

On Windows / Linux / BSD:

File -> Settings -> Tools -> External Tools

Click the + icon to add a new external tool with the following values:

Name: Black
Description: Black is the uncompromising Python code formatter.
Program: <install_location_from_step_2>
Arguments: "$FilePath$"
Format the currently opened file by selecting Tools -> External Tools -> black.

3、Alternatively, you can set a keyboard shortcut by navigating to Preferences or Settings -> Keymap -> External Tools -> External Tools - Black.
Optionally, run Black on every file save:

Make sure you have the File Watcher plugin installed.
Go to Preferences or Settings -> Tools -> File Watchers and click + to add a new watcher:
Name: Black
File type: Python
Scope: Project Files
Program: <install_location_from_step_2>
Arguments: $FilePath$
Output paths to refresh: $FilePath$
Working directory: $ProjectFileDir$
Uncheck "Auto-save edited files to trigger the watcher"

最新文章

  1. C#.NET 大型企业信息化系统集成快速开发平台 4.2 版本 - 更优美的Oracle数据库上的代码生成器
  2. 初识Jsoup之解析HTML
  3. 用Spring+Junit4.4进行测试(使用注解)
  4. 试一下SVG
  5. 右值引用、move与move constructor
  6. Netsharp快速入门(之7) 基础档案(工作区1 向导创建工作区)
  7. UTF-8和GBK有什么区别?
  8. 使用Volley StringRequest Get的方式进行发票查询操作
  9. 再造轮子之网易彩票-第二季(IOS 篇 by sixleaves)
  10. Dialog与FragmentDialog源代码分析
  11. 负载均衡软件LVS分析二(安装)
  12. 康盛(discuz )牛逼的PHP加解密算法函数
  13. 团队项目第二阶段个人进展——Day7
  14. Selenium WebDriver的实现及工作原理
  15. Vue学习之路2-项目初搭建
  16. abap 变量检查
  17. php+mysql简单的添加和删除小案例
  18. 【ShoppingPeeker】-基于Webkit内核的爬虫蜘蛛引擎 ShoppingWebCrawler的姊妹篇-可视化任务Web管理
  19. 从0开始安装fedora23的笔记-- 以及使用fedora的常规问题-3
  20. maven 错误列表

热门文章

  1. 实现一个兼容eleUI form表单的多选组件
  2. 2、ES6结构赋值和模板字符串
  3. python 输出‘\xe8\xb4\x9d\xe8\xb4\x9d’, ‘\xe6\x99\xb6\xe6\x99\xb6’, ‘\xe6\xac\xa2\xe6\xac\xa2’]
  4. 判断一个数组的长度用 Length 还是 SizeOf ?
  5. vue中样式被覆盖的问题
  6. Kubernetes addons 之 coredns部署
  7. Python3基础 函数 参数 在设定缺省值的情况下指明参数类型
  8. 【设备问题】罗技M590鼠标无法连接Macbook Pro问题解决
  9. Qt编写气体安全管理系统9-数据查询
  10. Android开发之高仿微信图片选择器