Skip to content

Commit 8fe225b

Browse files
authored
Merge pull request #288 from ipfilip/main
Fix python 3.10 errors (deprecated collections)
2 parents b466297 + 1a71fc1 commit 8fe225b

File tree

7 files changed

+35
-14
lines changed

7 files changed

+35
-14
lines changed

nixnet/_session/collection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from __future__ import print_function
44

55
import abc
6-
import collections
6+
try:
7+
from collections.abc import Sequence # python 3.3+
8+
except ImportError:
9+
from collections import Sequence # python 2.7
710
import typing # NOQA: F401
811

912
import six
@@ -12,7 +15,7 @@
1215

1316

1417
@six.add_metaclass(abc.ABCMeta)
15-
class Collection(collections.Sequence):
18+
class Collection(Sequence):
1619
"""Collection of items in a session."""
1720

1821
def __init__(self, handle):

nixnet/_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Iterable # python 3.3+
7+
except ImportError:
8+
from collections import Iterable # python 2.7
69
import typing # NOQA: F401
710

811
import six
@@ -30,7 +33,7 @@ def flatten_items(list):
3033
if ',' in list:
3134
_errors.raise_xnet_error(_cconsts.NX_ERR_INVALID_PROPERTY_VALUE)
3235
flattened = list
33-
elif isinstance(list, collections.Iterable):
36+
elif isinstance(list, Iterable):
3437
flattened = ",".join(list)
3538
elif list is None:
3639
# For FRAME_IN_STREAM / FRAME_OUT_STREAM

nixnet/database/_collection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Mapping # python 3.3+
7+
except ImportError:
8+
from collections import Mapping # python 2.7
69
import typing # NOQA: F401
710

811
import six
@@ -14,7 +17,7 @@
1417
from nixnet.database import _database_object # NOQA: F401
1518

1619

17-
class DbCollection(collections.Mapping):
20+
class DbCollection(Mapping):
1821
"""Collection of database objects."""
1922

2023
def __init__(self, handle, db_type, prop_id, factory):

nixnet/database/_dbc_attributes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Mapping # python 3.3+
7+
except ImportError:
8+
from collections import Mapping # python 2.7
69
import six
710
import typing # NOQA: F401
811

912
from nixnet import _funcs
1013
from nixnet import constants
1114

1215

13-
class DbcAttributeCollection(collections.Mapping):
16+
class DbcAttributeCollection(Mapping):
1417
"""Collection for accessing DBC attributes."""
1518

1619
def __init__(self, handle):

nixnet/database/_dbc_signal_value_table.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Mapping # python 3.3+
7+
except ImportError:
8+
from collections import Mapping # python 2.7
69
import six
710
import typing # NOQA: F401
811

912
from nixnet import _funcs
1013
from nixnet import constants
1114

1215

13-
class DbcSignalValueTable(collections.Mapping):
16+
class DbcSignalValueTable(Mapping):
1417
"""Collection for accessing a DBC signal value table."""
1518

1619
def __init__(self, handle):

nixnet/system/_collection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Iterable, Sized # python 3.3+
7+
except ImportError:
8+
from collections import Iterable, Sized # python 2.7
69
import typing # NOQA: F401
710

811
from nixnet import _cprops
912

1013

11-
class SystemCollection(collections.Iterable, collections.Sized):
14+
class SystemCollection(Iterable, Sized):
1215
"""Collection of System related objects."""
1316

1417
def __init__(self, handle, prop_id, factory):

nixnet/system/_databases.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
import collections
5+
try:
6+
from collections.abc import Mapping # python 3.3+
7+
except ImportError:
8+
from collections import Mapping # python 2.7
69
import typing # NOQA: F401
710

811
import six
912

1013
from nixnet import _funcs
1114

1215

13-
class AliasCollection(collections.Mapping):
16+
class AliasCollection(Mapping):
1417
"""Alias aliases."""
1518

1619
def __init__(self, handle):

0 commit comments

Comments
 (0)