Hướng dẫn black python pycharm
Edit this page Show Toggle table of contents sidebar Emacs#Options include the following:
PyCharm/IntelliJ IDEA#
Wing IDE#Wing IDE supports Prerequistes#
Preference Settings#If you want Wing IDE to always reformat with
Project Properties#If you want to just reformat for a specific project and not intervene with Wing IDE global setting, follow these steps:
Vim#Official plugin#Commands and shortcuts:
Configuration:
To install with vim-plug: Plug 'psf/black', { 'branch': 'stable' } or with Vundle: and execute the following in a terminal: $ cd ~/.vim/bundle/black $ git checkout origin/stable -b stable or you can copy the plugin files from plugin/black.vim and autoload/black.vim. mkdir -p ~/.vim/pack/python/start/black/plugin mkdir -p ~/.vim/pack/python/start/black/autoload curl https://raw.githubusercontent.com/psf/black/stable/plugin/black.vim -o ~/.vim/pack/python/start/black/plugin/black.vim curl https://raw.githubusercontent.com/psf/black/stable/autoload/black.vim -o ~/.vim/pack/python/start/black/autoload/black.vim Let me know if this requires any changes to work with Vim 8’s builtin
This plugin requires Vim 7.0+ built with Python 3.6+ support. It needs Python 3.6 to be able to run Black inside the Vim process which is much faster than calling an external command. On first run, the plugin creates its own virtualenv using the right Python version and automatically installs Black. You can upgrade it later by calling If you need to do anything special to make your
virtualenv work and install Black (for example you want to run a version from main), create a virtualenv manually and point To run Black on save, add the following lines to augroup black_on_save autocmd! autocmd BufWritePre *.py Black augroup end To run Black on a key press (e.g. F9 below), add this: How to get Vim with Python 3.6? On Ubuntu 17.10 Vim comes with Python 3.6 by default. On macOS with Homebrew run: I get an import error when using Black from a virtual environment: If you get an error message like this: Traceback (most recent call last): File " Then you need to install The package that causes problems is:
Now remove those two packages: $ pip uninstall typed-ast -y
And now you can install them with: $ pip install --no-binary :all: typed-ast
The C extensions will be compiled and now Vim’s Python environment will match. Note that you need to have the GCC compiler and the Python development files installed (on Ubuntu/Debian do If you later want to update Black, you should do it like this: $ pip install -U black --no-binary typed-ast
With ALE#
Gedit#gedit is the default text editor of the GNOME, Unix like Operating Systems. Open gedit as
#!/bin/bash Name=$GEDIT_CURRENT_DOCUMENT_NAME black $Name
Use your keyboard shortcut or Visual Studio Code#
SublimeText 3#Use sublack plugin. Python LSP Server#If your editor supports the Language Server Protocol (Atom, Sublime Text, Visual Studio Code and many more), you can use the Python LSP Server with the python-lsp-black plugin. Atom/Nuclide#Use python-black or formatters-python. Gradle (the build tool)#Use the Spotless plugin. Kakoune#Add the following hook to
your kakrc, then run Black with hook global WinSetOption filetype=python %{ set-option window formatcmd 'black -q -' } Thonny#Use Thonny-black-code-format. |