Skip to content

Commit 53ebc1b

Browse files
committed
isort: add configruation
I've attempted to keep the following considerations: Follow PEP8 recommendations. Having a widely used style is helpful for new contributors, for tooling, and is one of the nice features of python as an ecosystem. PEP8 recommends that imports are on a single line: ```python import json import os ``` not ```python import json, os ``` There are a number of advantages to this: - It's easier to read, especially when there are many imports - adding or subtracting imports makes smaller git changes, which makes rebases and merges easier PEP8 does recommend for using multiple imports when importing from (`from X import Y, Z`), and we do a lot of this. Therefore, I have used a format for that which attempts to strike a balance between readability and compactness. While I find: ```python from mod import ( one, two, three, ) ``` to be the most readable import syntax, there is an argument to be made that this often takes up a *lot* of vertical space, so the format I've configured does the following: ```python from mod import one, two three from other_mod import ( lots, of, modules, and, classes, that, are, imported, andthisreallylongonethatcauseawrap ) ``` By dropping to a new line we maximize the use of horizontal space, and thus vertical space. It also avoids situations like: ```python from mesonbuild.compilers.mixins.gnu import (GnuLikeMixin, GnuMixin) ``` Finally, I've configured isort to automatically add `from __future__ import annotations` to all python files. This has found a number of places it's missing, and allows us to catch this in a linter instead of having to manually inspect for that.
1 parent 9fa6f88 commit 53ebc1b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.isort.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[settings]
2+
py_version=37
3+
line_length=100
4+
use_parentheses=True
5+
multi_line_output=5
6+
add_imports=from __future__ import annotations

0 commit comments

Comments
 (0)