Skip to content

Commit

Permalink
Fix: deprecated collections imports
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rseragon committed Jul 27, 2023
1 parent 349a3be commit 3218c80
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion chemdataextractor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from __future__ import unicode_literals
import io
import os
from collections import MutableMapping
from collections.abc import MutableMapping

import appdirs
import yaml
Expand Down
4 changes: 2 additions & 2 deletions chemdataextractor/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from __future__ import unicode_literals

from abc import ABCMeta, abstractproperty
import collections
from collections.abc import Sequence
import io
import json
import logging
Expand All @@ -33,7 +33,7 @@


@python_2_unicode_compatible
class BaseDocument(six.with_metaclass(ABCMeta, collections.Sequence)):
class BaseDocument(six.with_metaclass(ABCMeta, Sequence)):
"""Abstract base class for a Document."""

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions chemdataextractor/doc/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from __future__ import print_function
from __future__ import unicode_literals
from abc import abstractproperty
import collections
from collections.abc import Sequence
import logging
import re

Expand Down Expand Up @@ -113,7 +113,7 @@ def _repr_html_(self):
return self.text


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

sentence_tokenizer = ChemSentenceTokenizer()
Expand Down
2 changes: 1 addition & 1 deletion chemdataextractor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import copy
from abc import ABCMeta
from collections import MutableSequence
from collections.abc import MutableSequence
import json
import logging

Expand Down
4 changes: 2 additions & 2 deletions chemdataextractor/parse/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import collections
from collections.abc import Sequence
import copy
import logging
import re
Expand Down Expand Up @@ -309,7 +309,7 @@ def __init__(self, exprs):
exprs = list(exprs)
if isinstance(exprs, six.text_type):
self.exprs = [Word(exprs)]
elif isinstance(exprs, collections.Sequence):
elif isinstance(exprs, Sequence):
if all(isinstance(expr, six.text_type) for expr in exprs):
exprs = map(Word, exprs)
self.exprs = list(exprs)
Expand Down
2 changes: 1 addition & 1 deletion chemdataextractor/scrape/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from collections import Sequence
from collections.abc import Sequence
import json
import logging

Expand Down
2 changes: 1 addition & 1 deletion chemdataextractor/scrape/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from collections import Sequence
from collections.abc import Sequence
from copy import deepcopy
import logging
import re
Expand Down

0 comments on commit 3218c80

Please sign in to comment.