mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-04-26 09:54:42 +00:00
Change typechecking with type to isinstance
This commit is contained in:
parent
4958bfd04b
commit
b9e788ab7d
3 changed files with 6 additions and 6 deletions
|
|
@ -91,7 +91,7 @@ def rewrite_q_expr(model_cls, expr):
|
|||
# Node in a Q-expr can be a Q or an attribute-value tuple (leaf).
|
||||
# We are only interested in Qs.
|
||||
|
||||
if type(expr) == Q:
|
||||
if isinstance(expr, Q):
|
||||
config_cls = getattr(model_cls, '_eav_config_cls', None)
|
||||
assert config_cls
|
||||
gr_name = config_cls.generic_relation_attr
|
||||
|
|
@ -114,7 +114,7 @@ def rewrite_q_expr(model_cls, expr):
|
|||
# Child to be merged is always a terminal Q node,
|
||||
# i.e. it's an AND expression with attribute-value tuple child.
|
||||
attrval = child.children[0]
|
||||
assert type(attrval) == tuple
|
||||
assert isinstance(attrval, tuple)
|
||||
|
||||
fname = '{}__in'.format(gr_name)
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ def expand_q_filters(q, root_cls):
|
|||
new_children = []
|
||||
|
||||
for qi in q.children:
|
||||
if type(qi) is tuple:
|
||||
if isinstance(qi, tuple):
|
||||
# This child is a leaf node: in Q this is a 2-tuple of:
|
||||
# (filter parameter, value).
|
||||
key, value = expand_eav_filter(root_cls, *qi)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ def print_q_expr(expr, indent="", is_tail=True):
|
|||
sys.stdout.write(indent)
|
||||
sa, sb = (' └── ', ' ') if is_tail else (' ├── ', ' │ ')
|
||||
|
||||
if type(expr) == Q:
|
||||
if isinstance(expr, Q):
|
||||
sys.stdout.write('{}{}\n'.format(sa, expr.connector))
|
||||
for child in expr.children:
|
||||
print_q_expr(child, indent + sb, expr.children[-1] == child)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ def validate_text(value):
|
|||
'''
|
||||
Raises ``ValidationError`` unless *value* type is ``str`` or ``unicode``
|
||||
'''
|
||||
if not type(value) == str:
|
||||
if not isinstance(value, str):
|
||||
raise ValidationError(_(u"Must be str or unicode"))
|
||||
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ def validate_bool(value):
|
|||
'''
|
||||
Raises ``ValidationError`` unless *value* type is ``bool``
|
||||
'''
|
||||
if not type(value) == bool:
|
||||
if not isinstance(value, bool):
|
||||
raise ValidationError(_(u"Must be a boolean"))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue