Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DuplicatePropertyError #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions couchdbkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from .version import version_info, __version__

from .resource import RequestFailed, CouchdbResource
from .exceptions import InvalidAttachment, DuplicatePropertyError,\
BadValueError, MultipleResultsFound, NoResultFound, ReservedWordError,\
DocsPathNotFound, BulkSaveError, ResourceNotFound, ResourceConflict, \
PreconditionFailed
from .exceptions import InvalidAttachment, BadValueError, \
MultipleResultsFound, NoResultFound, ReservedWordError, DocsPathNotFound, \
BulkSaveError, ResourceNotFound, ResourceConflict, PreconditionFailed

from .client import Server, Database, ViewResults
from .changes import ChangesStream
Expand Down
4 changes: 0 additions & 4 deletions couchdbkit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
class InvalidAttachment(Exception):
""" raised when an attachment is invalid """

class DuplicatePropertyError(Exception):
""" exception raised when there is a duplicate
property in a model """

class BadValueError(Exception):
""" exception raised when a value can't be validated
or is required """
Expand Down
11 changes: 1 addition & 10 deletions couchdbkit/schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from .properties import value_to_python, \
convert_property, MAP_TYPES_PROPERTIES, ALLOWED_PROPERTY_TYPES, \
LazyDict, LazyList
from ..exceptions import DuplicatePropertyError, ResourceNotFound, \
ReservedWordError
from ..exceptions import ResourceNotFound, ReservedWordError


__all__ = ['ReservedWordError', 'ALLOWED_PROPERTY_TYPES', 'DocumentSchema',
Expand Down Expand Up @@ -45,10 +44,6 @@ def __new__(cls, name, bases, attrs):
for base in bases:
if hasattr(base, '_properties'):
property_keys = base._properties.keys()
duplicate_properties = defined.intersection(property_keys)
if duplicate_properties:
raise DuplicatePropertyError(
'Duplicate properties in base class %s already defined: %s' % (base.__name__, list(duplicate_properties)))
defined.update(property_keys)
properties.update(base._properties)

Expand All @@ -64,17 +59,13 @@ def __new__(cls, name, bases, attrs):
# map properties
if isinstance(attr, p.Property):
check_reserved_words(attr_name)
if attr_name in defined:
raise DuplicatePropertyError('Duplicate property: %s' % attr_name)
properties[attr_name] = attr
attr.__property_config__(cls, attr_name)
# python types
elif type(attr) in MAP_TYPES_PROPERTIES and \
not attr_name.startswith('_') and \
attr_name not in _NODOC_WORDS:
check_reserved_words(attr_name)
if attr_name in defined:
raise DuplicatePropertyError('Duplicate property: %s' % attr_name)
prop = MAP_TYPES_PROPERTIES[type(attr)](default=attr)
properties[attr_name] = prop
prop.__property_config__(cls, attr_name)
Expand Down