Browse files

!= None to is not None

  • Loading branch information...
1 parent 5cf71da commit 71dc85c6ab690ce343b28363c176e21e355d8670 @jeffjenkins committed Aug 4, 2012
View
2 examples/advanced_modeling.py
@@ -18,7 +18,7 @@ class Event(Document):
def __init__(self, name, parent=None):
Document.__init__(self, name=name)
self.children = []
- if parent != None:
+ if parent is not None:
parent.children.append(self)
def __enter__(self):
self.begin = datetime.utcnow()
View
2 mongoalchemy/document.py
@@ -88,7 +88,7 @@ def __new__(mcs, classname, bases, class_dict):
new_class._fields[name] = maybefield
# 3. register type
- if new_class.config_namespace != None:
+ if new_class.config_namespace is not None:
name = new_class.config_full_name
if name == None:
name = new_class.__name__
View
2 mongoalchemy/exceptions.py
@@ -7,7 +7,7 @@ def __init__(self, name, value, reason, cause=None):
self.value = value
self.cause = cause
message = 'Bad value for field of type "%s". Reason: "%s".' % (name, reason)
- if cause != None:
+ if cause is not None:
message = '%s Cause: %s' % (message, cause)
Exception.__init__(self, message)
View
18 mongoalchemy/fields.py
@@ -249,7 +249,7 @@ def db_field(self):
the value is the name which this field was assigned to on the owning
document.
'''
- if self.__db_field != None:
+ if self.__db_field is not None:
return self.__db_field
return self._name
@@ -375,9 +375,9 @@ def validate_wrap(self, value):
''' Validates the type and length of ``value`` '''
if not isinstance(value, basestring):
self._fail_validation_type(value, basestring)
- if self.max != None and len(value) > self.max:
+ if self.max is not None and len(value) > self.max:
self._fail_validation(value, 'Value too long (%d)' % len(value))
- if self.min != None and len(value) < self.min:
+ if self.min is not None and len(value) < self.min:
self._fail_validation(value, 'Value too short (%d)' % len(value))
class BinaryField(PrimitiveField):
@@ -418,9 +418,9 @@ def validate_wrap(self, value, *types):
else:
self._fail_validation_type(value, *types)
- if self.min != None and value < self.min:
+ if self.min is not None and value < self.min:
self._fail_validation(value, 'Value too small')
- if self.max != None and value > self.max:
+ if self.max is not None and value > self.max:
self._fail_validation(value, 'Value too large')
class IntField(NumberField):
@@ -506,9 +506,9 @@ def validate_wrap(self, value):
return
# min/max
- if self.min != None and value < self.min:
+ if self.min is not None and value < self.min:
self._fail_validation(value, 'DateTime too old')
- if self.max != None and value > self.max:
+ if self.max is not None and value > self.max:
self._fail_validation(value, 'DateTime too new')
class TupleField(Field):
@@ -714,9 +714,9 @@ def _validate_child_unwrap(self, value, session=None):
self.item_type.validate_unwrap(value)
def _length_valid(self, value):
- if self.min != None and len(value) < self.min:
+ if self.min is not None and len(value) < self.min:
self._fail_validation(value, 'Value has too few elements')
- if self.max != None and len(value) > self.max:
+ if self.max is not None and len(value) > self.max:
self._fail_validation(value, 'Value has too many elements')
def validate_wrap(self, value):
View
4 mongoalchemy/session.py
@@ -225,9 +225,9 @@ def execute_query(self, query, session):
cursor.sort(query.sort)
if query.hints:
cursor.hint(query.hints)
- if query.get_limit() != None:
+ if query.get_limit() is not None:
cursor.limit(query.get_limit())
- if query.get_skip() != None:
+ if query.get_skip() is not None:
cursor.skip(query.get_skip())
return QueryResult(session, cursor, query.type, raw_output=query._raw_output, fields=query.get_fields())
View
2 test/test_util.py
@@ -13,4 +13,4 @@ def test_UNSET():
# for coverage
r = repr(UNSET)
assert UNSET == UNSET
- assert UNSET != None
+ assert UNSET is not None

0 comments on commit 71dc85c

Please sign in to comment.