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

sort import statements #8

Open
prjemian opened this issue Aug 6, 2019 · 4 comments
Open

sort import statements #8

prjemian opened this issue Aug 6, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@prjemian
Copy link
Contributor

prjemian commented Aug 6, 2019

To ease code maintenance, suggest sorting import statements. The bluesky community has been discussing code format and this was one of the topics.

There is an isort package that will do this for you. But we could do it manually first.

  1. group system imports first, blank line, then local imports
  2. in each group, sort alphabetically

Of course, some imports require other actions before them, such as appending to sys.path requires import sys first. That's expected.

@prjemian prjemian added the enhancement New feature or request label Aug 6, 2019
@prjemian prjemian self-assigned this Aug 6, 2019
@prjemian
Copy link
Contributor Author

prjemian commented Aug 6, 2019

Discuss before modifying code since

These imports can be sorted:

import socket
import getpass
import yaml
import bluesky
import ophyd
import apstools
import numpy as np
from datetime import datetime

to

 import apstools
 import bluesky 
 from datetime import datetime 
 import getpass 
 import numpy as np 
 import ophyd 
 import socket 
 import yaml 

without causing errors.

@prjemian
Copy link
Contributor Author

prjemian commented Aug 6, 2019

Similarly, these lines (in the print) should be sorted since they are for reference:

os
matplotlib
matplotlib.pyplot as plt <-- interactive, using widget as backend
socket
getpass
yaml
bluesky
ophyd
apstools
numpy
datetime
databroker

@prjemian
Copy link
Contributor Author

prjemian commented Aug 6, 2019

This line is not needed:

but we should convert:

to

RE = bluesky.RunEngine({})

@prjemian
Copy link
Contributor Author

prjemian commented Aug 6, 2019

Adding previous comment to #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants