-
Notifications
You must be signed in to change notification settings - Fork 197
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
Clean up imports of old modules #433
Clean up imports of old modules #433
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I'd like some discussion / reasoning about using absolute imports within the same package. DRY tells us to leave out the package name in places within the same package, and I've seen very few use cases where relative imports don't work.
@@ -4,7 +4,7 @@ | |||
from canopen.pdo.base import PdoBase, Maps | |||
|
|||
# Compatibility | |||
from .base import Variable | |||
from canopen.pdo.base import Variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change to absolute package reference here? I'd actually rather go the other way and use relative imports within the same package. Maybe it's a matter of taste, but I liked the old style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other reason that PEP 8 recommends using absolute imports, so it's become a habit for many projects. PEP 8 also states "explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose". So either is acceptable, but with preference to the former. And lastly, the rest of canopen is using absolute imports. I find it messy that the import styles are mixed.
@@ -4,4 +4,4 @@ | |||
from canopen.sdo.exceptions import SdoAbortedError, SdoCommunicationError | |||
|
|||
# Compatibility | |||
from .base import Variable, Record, Array | |||
from canopen.sdo.base import Variable, Record, Array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
The canopen package have import leftovers from earlier versions of Python. This PR cleans up the no longer valid imports.
import Queue
dates to py 2import collections.*Mapping
was changed tocollections.abc.*Mapping
in py 3.3import ConfigParser
dates to py 2import xml.etree.cElementTree
is deprecated since py 3.3. It will pick the fastest option when usingxml.etree.ElementTree
.base
intocanopen.pdo.base
in canopen/pdo/init.py.base
intocanopen.sdo.base
in canopen/sdo/init.py