Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add an isort configuration #3463

Merged
merged 8 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added changelog.d/3463.misc
Empty file.
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ max-line-length = 90
# W503 requires that binary operators be at the end, not start, of lines. Erik doesn't like it.
# E203 is contrary to PEP8.
ignore = W503,E203

[isort]
line_length = 89
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whyso?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match our flake8 configuration, basically.

not_skip = __init__.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whyso?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, isort skips init files. We put a lot of implementation code in init files, so we have to run them on it too.

sections=FUTURE,STDLIB,COMPAT,THIRDPARTY,TWISTED,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
known_first_party = synapse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to include tests in this too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

known_compat = mock,six
known_twisted=twisted,OpenSSL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced about putting mock, six, twisted and OpenSSL in separate groups. What's the thinking there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning for six being separate is that when we go Py3 only, that compat section gets removed (as six isn't needed and mock is in the stdlib in py3).

Twisted being separate is basically aesthetics for me, I added it after a test run to see how it would look. Since we import so much from it, it just adds a bit of whitespace between all those imports and the other third party ones, otherwise the list can get pretty dense.

multi_line_output=3
include_trailing_comma=true