Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion on the ordering of library imports #182

Closed
eurunuela opened this issue Mar 20, 2020 · 8 comments · Fixed by #195
Closed

Discussion on the ordering of library imports #182

eurunuela opened this issue Mar 20, 2020 · 8 comments · Fixed by #195
Assignees
Labels
Discussion Discussion of a concept or implementation. Need to stay always open.

Comments

@eurunuela
Copy link
Collaborator

Summary

Each one of us has got a different way of ordering the library imports and I believe we should have some guidelines to follow. The idea is that we are all on the same page. Also, this should make reading and reviewing the code easier on the eye.

The following is a possible guideline:

  1. Standard library imports
  2. Third-party library imports
  3. Internal library imports

where each set of imports is in alphabetical order, ideally separated by a blank line.

If you agree on making the suggested guideline the default, please upvote. If you have a better suggestion, please comment on this issue. I will keep this issue open for a week and will open a PR that updates the imports with whatever guideline has got the most upvotes once the issue is closed.

Tagging the most active members in the project: @smoia, @vinferrer, @rmarkello, @RayStick.

Next Steps

  • Open a PR that updates the imports following the outcome of this discussion.
@eurunuela eurunuela added the Discussion Discussion of a concept or implementation. Need to stay always open. label Mar 20, 2020
@eurunuela eurunuela self-assigned this Mar 20, 2020
@smoia
Copy link
Member

smoia commented Mar 24, 2020

Totally agree! This would follow better PEP8 conventions.
What would you (all) prefer as order:
case 1:

import matplotlib.pyplot as plt
import scipy.signal
from numpy import array

or case 2:

import matplotlib.pyplot as plt
from numpy import array
import scipy.signal

?

PEP8 doesn't specify this case.

@eurunuela
Copy link
Collaborator Author

I like the first proposal better.

May I ask you to only upvote the guideline you would like to be implemented? This means you should remove the upvote from the first proposal if you'd like to vote for another one.

@smoia
Copy link
Member

smoia commented Mar 24, 2020

Ok, let's try again,

It seems that we agree to follow PEP8 conventions.

Is the difference you see between just following alphabetical order (case 2) vs import/from distinctions (case 1)?

@eurunuela
Copy link
Collaborator Author

Oh, I follow you.

I'd rather have import first, then from.

@smoia
Copy link
Member

smoia commented Mar 24, 2020

Then, final vote:
@eurunuela @rmarkello @RayStick @vinferrer and all the others that want to express a preference, knowing that we will follow PEP8 standards as proposed by @eurunuela, vote with a:
🎉 for case 1 (import first and from second, but alphabetical within them):

import os
import sys

import matplotlib.pyplot as plt
import scipy.signal
from numpy import array
from pandas import Series

import phys2bids.viz
from phys2bids import utils

or 🚀 for case 2 (strict alphabetical order):

import os
import sys

import matplotlib.pyplot as plt
from numpy import array
from pandas import Series
import scipy.signal

from phys2bids import utils
import phys2bids.viz

@vinferrer
Copy link
Collaborator

after voting, should we make a bit PR to change the order in all the files?

@eurunuela
Copy link
Collaborator Author

Don't worry @vinferrer, I'll take care of it. Just make sure that whatever you're working in right now follows the new guidelines before merging!

@vinferrer
Copy link
Collaborator

sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Discussion of a concept or implementation. Need to stay always open.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants