Skip to content

Commit

Permalink
Fixed collections ABCs deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
pri22296 committed Aug 19, 2018
1 parent f503414 commit 46af923
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions beautifultable/beautifultable.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@
import itertools
import copy
import operator
import collections
import warnings

try:
# Python 3
from collections.abc import Iterable
except ImportError:
# Python 2.7
from collections import Iterable

from .utils import get_output_str, raise_suppressed
from .rows import RowData, HeaderData
from .meta import AlignmentMetaData, PositiveIntegerMetaData
Expand Down Expand Up @@ -430,7 +436,7 @@ def _validate_row(self, value, init_table_if_required=True):
# TODO: Rename this method
# str is also an iterable but it is not a valid row, so
# an extra check is required for str
if not isinstance(value, collections.Iterable) or isinstance(value, str):
if not isinstance(value, Iterable) or isinstance(value, str):
raise TypeError("parameter must be an iterable")

row = list(value)
Expand Down Expand Up @@ -540,7 +546,7 @@ def __len__(self):
def __contains__(self, key):
if isinstance(key, str):
return key in self._column_headers
elif isinstance(key, collections.Iterable):
elif isinstance(key, Iterable):
return key in self._table
else:
raise TypeError("'key' must be str or Iterable, not {}".format(type(key).__name__))
Expand Down

0 comments on commit 46af923

Please sign in to comment.