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

Clean up imports of old modules #433

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 1 addition & 4 deletions canopen/lss.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import logging
import time
import struct
try:
import queue
except ImportError:
import Queue as queue
import queue

logger = logging.getLogger(__name__)

Expand Down
5 changes: 1 addition & 4 deletions canopen/network.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from collections.abc import MutableMapping
except ImportError:
from collections import MutableMapping
from collections.abc import MutableMapping
import logging
import threading
from typing import Callable, Dict, Iterable, List, Optional, Union
Expand Down
5 changes: 1 addition & 4 deletions canopen/objectdictionary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"""
import struct
from typing import Dict, Iterable, List, Optional, TextIO, Union
try:
from collections.abc import MutableMapping, Mapping
except ImportError:
from collections import MutableMapping, Mapping
from collections.abc import MutableMapping, Mapping
import logging

from canopen.objectdictionary.datatypes import *
Expand Down
6 changes: 1 addition & 5 deletions canopen/objectdictionary/eds.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import copy
import logging
import re

try:
from configparser import RawConfigParser, NoOptionError, NoSectionError
except ImportError:
from ConfigParser import RawConfigParser, NoOptionError, NoSectionError
from configparser import RawConfigParser, NoOptionError, NoSectionError

from canopen import objectdictionary
from canopen.objectdictionary import ObjectDictionary, datatypes
Expand Down
5 changes: 1 addition & 4 deletions canopen/objectdictionary/epf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
import xml.etree.cElementTree as etree
except ImportError:
import xml.etree.ElementTree as etree
import xml.etree.ElementTree as etree
import logging

from canopen import objectdictionary
Expand Down
2 changes: 1 addition & 1 deletion canopen/pdo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from canopen.pdo.base import PdoBase, Maps

# Compatibility
from .base import Variable
from canopen.pdo.base import Variable
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.


logger = logging.getLogger(__name__)

Expand Down
5 changes: 1 addition & 4 deletions canopen/pdo/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import threading
import math
from typing import Callable, Dict, Iterable, List, Optional, Union
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
from collections.abc import Mapping
import logging
import binascii

Expand Down
2 changes: 1 addition & 1 deletion canopen/sdo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

5 changes: 1 addition & 4 deletions canopen/sdo/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import binascii
from typing import Iterable, Optional, Union
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
from collections.abc import Mapping

from canopen import objectdictionary
from canopen.objectdictionary import ObjectDictionary
Expand Down
5 changes: 1 addition & 4 deletions canopen/sdo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import logging
import io
import time
try:
import queue
except ImportError:
import Queue as queue
import queue

from canopen.network import CanError
from canopen import objectdictionary
Expand Down
5 changes: 1 addition & 4 deletions canopen/variable.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import logging
from typing import Union
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
from collections.abc import Mapping

from canopen import objectdictionary

Expand Down
Loading