You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments