Skip to content

Commit 26a68b5

Browse files
authored
Clean up imports of old modules (#433)
Remove compatibility leftovers from earlier versions of Python. Minimum version as of now is Python 3.6. * import Queue dates to Python 2 * import collections.*Mapping was changed to collections.abc.*Mapping in Python 3.3 * import ConfigParser dates to Python 2 * import xml.etree.cElementTree is deprecated since Python 3.3. It will pick the fastest option when using xml.etree.ElementTree. Fix some package relative imports to be consistent with surrounding code.
1 parent b55ce5c commit 26a68b5

File tree

11 files changed

+11
-39
lines changed

11 files changed

+11
-39
lines changed

canopen/lss.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import logging
22
import time
33
import struct
4-
try:
5-
import queue
6-
except ImportError:
7-
import Queue as queue
4+
import queue
85

96
logger = logging.getLogger(__name__)
107

canopen/network.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
from collections.abc import MutableMapping
3-
except ImportError:
4-
from collections import MutableMapping
1+
from collections.abc import MutableMapping
52
import logging
63
import threading
74
from typing import Callable, Dict, Iterable, List, Optional, Union

canopen/objectdictionary/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"""
44
import struct
55
from typing import Dict, Iterable, List, Optional, TextIO, Union
6-
try:
7-
from collections.abc import MutableMapping, Mapping
8-
except ImportError:
9-
from collections import MutableMapping, Mapping
6+
from collections.abc import MutableMapping, Mapping
107
import logging
118

129
from canopen.objectdictionary.datatypes import *

canopen/objectdictionary/eds.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import copy
22
import logging
33
import re
4-
5-
try:
6-
from configparser import RawConfigParser, NoOptionError, NoSectionError
7-
except ImportError:
8-
from ConfigParser import RawConfigParser, NoOptionError, NoSectionError
4+
from configparser import RawConfigParser, NoOptionError, NoSectionError
95

106
from canopen import objectdictionary
117
from canopen.objectdictionary import ObjectDictionary, datatypes

canopen/objectdictionary/epf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
import xml.etree.cElementTree as etree
3-
except ImportError:
4-
import xml.etree.ElementTree as etree
1+
import xml.etree.ElementTree as etree
52
import logging
63

74
from canopen import objectdictionary

canopen/pdo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from canopen.pdo.base import PdoBase, Maps
55

66
# Compatibility
7-
from .base import Variable
7+
from canopen.pdo.base import Variable
88

99
logger = logging.getLogger(__name__)
1010

canopen/pdo/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import threading
22
import math
33
from typing import Callable, Dict, Iterable, List, Optional, Union
4-
try:
5-
from collections.abc import Mapping
6-
except ImportError:
7-
from collections import Mapping
4+
from collections.abc import Mapping
85
import logging
96
import binascii
107

canopen/sdo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from canopen.sdo.exceptions import SdoAbortedError, SdoCommunicationError
55

66
# Compatibility
7-
from .base import Variable, Record, Array
7+
from canopen.sdo.base import Variable, Record, Array

canopen/sdo/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import binascii
22
from typing import Iterable, Optional, Union
3-
try:
4-
from collections.abc import Mapping
5-
except ImportError:
6-
from collections import Mapping
3+
from collections.abc import Mapping
74

85
from canopen import objectdictionary
96
from canopen.objectdictionary import ObjectDictionary

canopen/sdo/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import logging
33
import io
44
import time
5-
try:
6-
import queue
7-
except ImportError:
8-
import Queue as queue
5+
import queue
96

107
from canopen.network import CanError
118
from canopen import objectdictionary

canopen/variable.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import logging
22
from typing import Union
3-
try:
4-
from collections.abc import Mapping
5-
except ImportError:
6-
from collections import Mapping
3+
from collections.abc import Mapping
74

85
from canopen import objectdictionary
96

0 commit comments

Comments
 (0)