Skip to content

Commit

Permalink
Imports abstract base classes from the platform module
Browse files Browse the repository at this point in the history
Closes #450
  • Loading branch information
funkyfuture committed Oct 10, 2018
1 parent 5d3ccc0 commit da16545
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
26 changes: 26 additions & 0 deletions cerberus/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,29 @@
else:
_str_type = str
_int_types = (int,)


if PYTHON_VERSION < 3.3:
from collections import ( # noqa: F401
Callable,
Container,
Hashable,
Iterable,
Mapping,
MutableMapping,
Sequence,
Set,
Sized,
)
else:
from collections.abc import ( # noqa: F401
Callable,
Container,
Hashable,
Iterable,
Mapping,
MutableMapping,
Sequence,
Set,
Sized,
)
2 changes: 1 addition & 1 deletion cerberus/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import absolute_import

from collections import Callable, Hashable, Mapping, MutableMapping, Sequence
from copy import copy
from warnings import warn

Expand All @@ -12,6 +11,7 @@
mapping_hash,
TypeDefinition,
)
from cerberus.platform import Callable, Hashable, Mapping, MutableMapping, Sequence


class _Abort(Exception):
Expand Down
4 changes: 2 additions & 2 deletions cerberus/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import absolute_import

from collections import Mapping, namedtuple, Sequence, Set
from collections import namedtuple

from cerberus.platform import _int_types, _str_type
from cerberus.platform import _int_types, _str_type, Mapping, Sequence, Set


TypeDefinition = namedtuple('TypeDefinition', 'name,included_types,excluded_types')
Expand Down
13 changes: 10 additions & 3 deletions cerberus/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@
from __future__ import absolute_import

from ast import literal_eval
from collections import Container, Hashable, Iterable, Mapping, Sequence, Sized
from copy import copy
from datetime import date, datetime
import re
from warnings import warn

from cerberus import errors
from cerberus.platform import _int_types, _str_type
from cerberus.platform import (
_int_types,
_str_type,
Container,
Hashable,
Iterable,
Mapping,
Sequence,
Sized,
)
from cerberus.schema import (
schema_registry,
rules_set_registry,
Expand All @@ -27,7 +35,6 @@
)
from cerberus.utils import drop_item_from_tuple, readonly_classproperty, TypeDefinition


toy_error_handler = errors.ToyErrorHandler()


Expand Down

0 comments on commit da16545

Please sign in to comment.