-python-version: Tells isort to set the known standard library based on the specified Python version.Profiles include: black, django, pycharm, google, open_stack, plone, attrs, hug. -profile: Base profile type to use for configuration.-multi-line: Multi line output (0-grid, 1-vertical, 2-hanging, 3-vert-hanging, 4-vert-grid, 5-vert-grid-grouped, 6-vert-grid-grouped-no-comma, 7-noqa, 8-vertical-hanging-indent-bracket, 9-vertical-prefix-from-module-import, 10-hanging-indent-with-parentheses).The options used are mainly to be compatible with black (see here): Isort -multi-line 3 -profile black -python-version 27. So it’s as simple as running the following code at the root of my project and all non-compliant files will be reformatted: My preference is using PEP 8 as my style guide, and so, 79-characters per line of code is what I use. With black you can format Python code from 2.7 all the way to 3.8 (as of version 20.8b1), which makes for a great replacement of YAPF which can only format code depending on the Python version being used to run it. So let’s begin by describing each tool, and how I use them. In, what is now, part 1 I mentioned that due to some work-related projects I still write Python 2 code, but as everyone is dropping support for Python 2, I have decided to use Python 3 tools to format my code. On this installment I will discuss how I use tools like black, isort, flake8, and how to put it all together using pre-commit. Welcome to part 2 of my series on how code formatters can assist in producing easy-to-read code, and hopefully easy to maintain too.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |