-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #2
base: master
Are you sure you want to change the base?
Conversation
if value and not datatype == attribute.TYPE_ENUM: #enum done above | ||
if value and datatype != attribute.TYPE_ENUM: #enum done above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function BaseDynamicEntityForm._build_dynamic_fields
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
if self.datatype == self.TYPE_ENUM: | ||
if value not in self.enum_group.enums.all(): | ||
raise ValidationError(_(u"%(enum)s is not a valid choice " | ||
u"for %(attr)s") % \ | ||
{'enum': value, 'attr': self}) | ||
if ( | ||
self.datatype == self.TYPE_ENUM | ||
and value not in self.enum_group.enums.all() | ||
): | ||
raise ValidationError(_(u"%(enum)s is not a valid choice " | ||
u"for %(attr)s") % \ | ||
{'enum': value, 'attr': self}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Attribute.validate_value
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
if not self.datatype == Attribute.TYPE_ENUM: | ||
if self.datatype != Attribute.TYPE_ENUM: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Attribute.get_choices
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
if value == None or value == '': | ||
if value in [None, '']: | ||
return | ||
value_obj = Value.objects.create(entity_ct=ct, | ||
entity_id=entity.pk, | ||
attribute=self) | ||
if value == None or value == '': | ||
if value is None or value == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Attribute.save_value
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
) - Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
if self.attribute.datatype == Attribute.TYPE_ENUM and \ | ||
self.value_enum: | ||
if self.value_enum not in self.attribute.enum_group.enums.all(): | ||
raise ValidationError(_(u"%(choice)s is not a valid " \ | ||
u"choice for %s(attribute)") % \ | ||
{'choice': self.value_enum, | ||
'attribute': self.attribute}) | ||
if ( | ||
self.attribute.datatype == Attribute.TYPE_ENUM | ||
and self.value_enum | ||
and self.value_enum not in self.attribute.enum_group.enums.all() | ||
): | ||
raise ValidationError(_(u"%(choice)s is not a valid " \ | ||
u"choice for %s(attribute)") % \ | ||
{'choice': self.value_enum, | ||
'attribute': self.attribute}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Value.clean
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
values_dict = dict() | ||
values_dict = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Entity.get_values_dict
refactored with the following changes:
- Replace dict() with {} (
dict-literal
)
if not (type(value) == unicode or type(value) == str): | ||
if not type(value) in [unicode, str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function validate_text
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
if not type(value) == bool: | ||
if type(value) != bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function validate_bool
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.02 out of 10.
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: