Skip to content

Commit 3218c80

Browse files
committed
Fix: deprecated collections imports
Imports like Sequence, MutableSequence, etc. are deprecated since python3.3 and are removed from 3.8. This commit fixes these import problems for users with 3.8+ ref: python/cpython#81505
1 parent 349a3be commit 3218c80

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

chemdataextractor/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from __future__ import unicode_literals
1414
import io
1515
import os
16-
from collections import MutableMapping
16+
from collections.abc import MutableMapping
1717

1818
import appdirs
1919
import yaml

chemdataextractor/doc/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from __future__ import unicode_literals
1414

1515
from abc import ABCMeta, abstractproperty
16-
import collections
16+
from collections.abc import Sequence
1717
import io
1818
import json
1919
import logging
@@ -33,7 +33,7 @@
3333

3434

3535
@python_2_unicode_compatible
36-
class BaseDocument(six.with_metaclass(ABCMeta, collections.Sequence)):
36+
class BaseDocument(six.with_metaclass(ABCMeta, Sequence)):
3737
"""Abstract base class for a Document."""
3838

3939
def __repr__(self):

chemdataextractor/doc/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function
1313
from __future__ import unicode_literals
1414
from abc import abstractproperty
15-
import collections
15+
from collections.abc import Sequence
1616
import logging
1717
import re
1818

@@ -113,7 +113,7 @@ def _repr_html_(self):
113113
return self.text
114114

115115

116-
class Text(collections.Sequence, BaseText):
116+
class Text(Sequence, BaseText):
117117
"""A passage of text, comprising one or more sentences."""
118118

119119
sentence_tokenizer = ChemSentenceTokenizer()

chemdataextractor/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import copy
1616
from abc import ABCMeta
17-
from collections import MutableSequence
17+
from collections.abc import MutableSequence
1818
import json
1919
import logging
2020

chemdataextractor/parse/elements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__ import division
1212
from __future__ import print_function
1313
from __future__ import unicode_literals
14-
import collections
14+
from collections.abc import Sequence
1515
import copy
1616
import logging
1717
import re
@@ -309,7 +309,7 @@ def __init__(self, exprs):
309309
exprs = list(exprs)
310310
if isinstance(exprs, six.text_type):
311311
self.exprs = [Word(exprs)]
312-
elif isinstance(exprs, collections.Sequence):
312+
elif isinstance(exprs, Sequence):
313313
if all(isinstance(expr, six.text_type) for expr in exprs):
314314
exprs = map(Word, exprs)
315315
self.exprs = list(exprs)

chemdataextractor/scrape/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__ import division
1212
from __future__ import print_function
1313
from __future__ import unicode_literals
14-
from collections import Sequence
14+
from collections.abc import Sequence
1515
import json
1616
import logging
1717

chemdataextractor/scrape/selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from __future__ import division
1212
from __future__ import print_function
1313
from __future__ import unicode_literals
14-
from collections import Sequence
14+
from collections.abc import Sequence
1515
from copy import deepcopy
1616
import logging
1717
import re

0 commit comments

Comments
 (0)