For discussion: use isort for formatting import#8046
For discussion: use isort for formatting import#8046ikkoham wants to merge 5 commits intoQiskit:mainfrom
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
|
I'll preface this by saying that I don't feel very strongly. Personally, I don't remember ever having had any serious issue caused by import order, either as a merge conflict or by having difficulty reading them. If I have had a merge conflict with them, it was so trivial to solve that I don't remember it. On the other hand, I'm concerned about the on-boarding cost to developers by adding another tool that they have to learn and configure if it's not providing us with much benefit. My vote would be against this, as the supposed benefits don't seem sufficient to justify the cost to new or external developers, but I'm aware that's somewhat subjective and others might feel more strongly. I think I used to be more in favour of this sort of tool, but as I work with others, and particularly getting new contributors started, it's dropped in my estimations a bit. I like code formatters in general, I just don't like a fragmented ecosystem of several of them. I know Lev's thought about doing this before as well (@levbishop). |
|
Thanks @jakelishman. I also don't remember when, but there were different developers with different isort settings, and every time they updated, they alternated the changes just like ping-pong... |
|
I did explore some of these ideas a few months ago on my branch https://github.com/levbishop/qiskit-terra/tree/isort
and adds some comments with the
vs
I actually rather like the google recommendation here, but we don't generally follow it in qiskit, and without it the google isort settings make the import sections way too verbose. I don't think the effort to switch over to the google style of importing modules only would come close to being worthwhile (unless maybe there were a tool that could do it in the manner of My current thoughts would be that if we make a change like this, then to do all of steps 1-3, probably don't do 4, definitely don't do 5. I think with 1-3 only then its low-impact on contributors to add CI checking of the isort usage, since its easy to get the sectioning correct by hand. If we add 4 then I tend to agree with @jakelishman that it's adding the barrier for contributors and for not-much benefit. I'm skeptical about the claimed merge-conflict resolution. As a compromise we could turn off |
|
Close this PR. If someone wants to continue this, please reopen. |
Summary
Terra introduced black formatter in #6361. However, there is currently no formatting for imports.
Developer's style differences regarding line breaks and ordering of imports can cause merge conflicts
as well as make code difficult to read.
isortis a formatter compatible with black. The developmentflow will be the same as when black was introduced, and there will be no major changes for developers.
Details and comments
if this direction looks good, I will modify contibution guidelines, etc.
References