Removed unnecessary parentheses in model check messages.

This commit is contained in:
Tim Graham 2015-02-09 08:53:58 -05:00
parent 4d73303ee9
commit e144e0e237
2 changed files with 50 additions and 45 deletions

View File

@ -1206,7 +1206,8 @@ class Model(six.with_metaclass(ModelBase)):
app_label, model_name = cls._meta.swapped.split('.') app_label, model_name = cls._meta.swapped.split('.')
errors.append( errors.append(
checks.Error( checks.Error(
("'%s' references '%s.%s', which has not been installed, or is abstract.") % ( "'%s' references '%s.%s', which has not been "
"installed, or is abstract." % (
cls._meta.swappable, app_label, model_name cls._meta.swappable, app_label, model_name
), ),
hint=None, hint=None,
@ -1272,8 +1273,8 @@ class Model(six.with_metaclass(ModelBase)):
if signature in seen_intermediary_signatures: if signature in seen_intermediary_signatures:
errors.append( errors.append(
checks.Error( checks.Error(
("The model has two many-to-many relations through " "The model has two many-to-many relations through "
"the intermediate model '%s.%s'.") % ( "the intermediate model '%s.%s'." % (
f.rel.through._meta.app_label, f.rel.through._meta.app_label,
f.rel.through._meta.object_name f.rel.through._meta.object_name
), ),
@ -1296,8 +1297,8 @@ class Model(six.with_metaclass(ModelBase)):
if fields and not fields[0].primary_key and cls._meta.pk.name == 'id': if fields and not fields[0].primary_key and cls._meta.pk.name == 'id':
return [ return [
checks.Error( checks.Error(
("'id' can only be used as a field name if the field also " "'id' can only be used as a field name if the field also "
"sets 'primary_key=True'."), "sets 'primary_key=True'.",
hint=None, hint=None,
obj=cls, obj=cls,
id='models.E004', id='models.E004',
@ -1320,9 +1321,9 @@ class Model(six.with_metaclass(ModelBase)):
if clash: if clash:
errors.append( errors.append(
checks.Error( checks.Error(
("The field '%s' from parent model " "The field '%s' from parent model "
"'%s' clashes with the field '%s' " "'%s' clashes with the field '%s' "
"from parent model '%s'.") % ( "from parent model '%s'." % (
clash.name, clash.model._meta, clash.name, clash.model._meta,
f.name, f.model._meta f.name, f.model._meta
), ),
@ -1347,8 +1348,8 @@ class Model(six.with_metaclass(ModelBase)):
if clash and not id_conflict: if clash and not id_conflict:
errors.append( errors.append(
checks.Error( checks.Error(
("The field '%s' clashes with the field '%s' " "The field '%s' clashes with the field '%s' "
"from model '%s'.") % ( "from model '%s'." % (
f.name, clash.name, clash.model._meta f.name, clash.name, clash.model._meta
), ),
hint=None, hint=None,
@ -1374,7 +1375,8 @@ class Model(six.with_metaclass(ModelBase)):
if column_name and column_name in used_column_names: if column_name and column_name in used_column_names:
errors.append( errors.append(
checks.Error( checks.Error(
"Field '%s' has column name '%s' that is used by another field." % (f.name, column_name), "Field '%s' has column name '%s' that is used by "
"another field." % (f.name, column_name),
hint="Specify a 'db_column' for the field.", hint="Specify a 'db_column' for the field.",
obj=cls, obj=cls,
id='models.E007' id='models.E007'
@ -1462,7 +1464,9 @@ class Model(six.with_metaclass(ModelBase)):
except KeyError: except KeyError:
errors.append( errors.append(
checks.Error( checks.Error(
"'%s' refers to the non-existent field '%s'." % (option, field_name), "'%s' refers to the non-existent field '%s'." % (
option, field_name,
),
hint=None, hint=None,
obj=cls, obj=cls,
id='models.E012', id='models.E012',
@ -1472,9 +1476,9 @@ class Model(six.with_metaclass(ModelBase)):
if isinstance(field.rel, models.ManyToManyRel): if isinstance(field.rel, models.ManyToManyRel):
errors.append( errors.append(
checks.Error( checks.Error(
("'%s' refers to a ManyToManyField '%s', but " "'%s' refers to a ManyToManyField '%s', but "
"ManyToManyFields are not permitted in '%s'.") % ( "ManyToManyFields are not permitted in '%s'." % (
option, field_name, option option, field_name, option,
), ),
hint=None, hint=None,
obj=cls, obj=cls,
@ -1486,7 +1490,7 @@ class Model(six.with_metaclass(ModelBase)):
checks.Error( checks.Error(
("'%s' refers to field '%s' which is not local " ("'%s' refers to field '%s' which is not local "
"to model '%s'.") % ( "to model '%s'.") % (
option, field_name, cls._meta.object_name option, field_name, cls._meta.object_name,
), ),
hint=("This issue may be caused by multi-table " hint=("This issue may be caused by multi-table "
"inheritance."), "inheritance."),

View File

@ -114,8 +114,8 @@ class IndexTogetherTests(IsolatedModelsTestCase):
errors = Bar.check() errors = Bar.check()
expected = [ expected = [
Error( Error(
("'index_together' refers to field 'field1' which is not " "'index_together' refers to field 'field1' which is not "
"local to model 'Bar'."), "local to model 'Bar'.",
hint=("This issue may be caused by multi-table inheritance."), hint=("This issue may be caused by multi-table inheritance."),
obj=Bar, obj=Bar,
id='models.E016', id='models.E016',
@ -135,8 +135,8 @@ class IndexTogetherTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
("'index_together' refers to a ManyToManyField 'm2m', but " "'index_together' refers to a ManyToManyField 'm2m', but "
"ManyToManyFields are not permitted in 'index_together'."), "ManyToManyFields are not permitted in 'index_together'.",
hint=None, hint=None,
obj=Model, obj=Model,
id='models.E013', id='models.E013',
@ -241,8 +241,8 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
("'unique_together' refers to a ManyToManyField 'm2m', but " "'unique_together' refers to a ManyToManyField 'm2m', but "
"ManyToManyFields are not permitted in 'unique_together'."), "ManyToManyFields are not permitted in 'unique_together'.",
hint=None, hint=None,
obj=Model, obj=Model,
id='models.E013', id='models.E013',
@ -330,9 +330,9 @@ class FieldNamesTests(IsolatedModelsTestCase):
m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id" m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id"
expected = [ expected = [
Error( Error(
('Autogenerated column name too long for M2M field "%s". ' 'Autogenerated column name too long for M2M field "%s". '
'Maximum length is "%s" for database "%s".' 'Maximum length is "%s" for database "%s".'
% (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias)), % (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias),
hint=("Use 'through' to create a separate model for " hint=("Use 'through' to create a separate model for "
"M2M and then set column_name using 'db_column'."), "M2M and then set column_name using 'db_column'."),
obj=ModelWithLongField, obj=ModelWithLongField,
@ -347,9 +347,9 @@ class FieldNamesTests(IsolatedModelsTestCase):
# name is longer than the limits of the database. # name is longer than the limits of the database.
expected.append( expected.append(
Error( Error(
('Autogenerated column name too long for M2M field "%s_id". ' 'Autogenerated column name too long for M2M field "%s_id". '
'Maximum length is "%s" for database "%s".' 'Maximum length is "%s" for database "%s".'
% (long_field_name, self.max_column_name_length, self.column_limit_db_alias)), % (long_field_name, self.max_column_name_length, self.column_limit_db_alias),
hint=("Use 'through' to create a separate model for " hint=("Use 'through' to create a separate model for "
"M2M and then set column_name using 'db_column'."), "M2M and then set column_name using 'db_column'."),
obj=ModelWithLongField, obj=ModelWithLongField,
@ -382,9 +382,9 @@ class FieldNamesTests(IsolatedModelsTestCase):
# without specifying db_column # without specifying db_column
expected = [ expected = [
Error( Error(
('Autogenerated column name too long for field "%s". ' 'Autogenerated column name too long for field "%s". '
'Maximum length is "%s" for database "%s".' 'Maximum length is "%s" for database "%s".'
% (long_field_name, self.max_column_name_length, self.column_limit_db_alias)), % (long_field_name, self.max_column_name_length, self.column_limit_db_alias),
hint="Set the column name manually using 'db_column'.", hint="Set the column name manually using 'db_column'.",
obj=ModelWithLongField, obj=ModelWithLongField,
id='models.E018', id='models.E018',
@ -441,17 +441,17 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
errors = Child.check() errors = Child.check()
expected = [ expected = [
Error( Error(
("The field 'id' from parent model " "The field 'id' from parent model "
"'invalid_models_tests.mother' clashes with the field 'id' " "'invalid_models_tests.mother' clashes with the field 'id' "
"from parent model 'invalid_models_tests.father'."), "from parent model 'invalid_models_tests.father'.",
hint=None, hint=None,
obj=Child, obj=Child,
id='models.E005', id='models.E005',
), ),
Error( Error(
("The field 'clash' from parent model " "The field 'clash' from parent model "
"'invalid_models_tests.mother' clashes with the field 'clash' " "'invalid_models_tests.mother' clashes with the field 'clash' "
"from parent model 'invalid_models_tests.father'."), "from parent model 'invalid_models_tests.father'.",
hint=None, hint=None,
obj=Child, obj=Child,
id='models.E005', id='models.E005',
@ -474,8 +474,8 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
errors = Child.check() errors = Child.check()
expected = [ expected = [
Error( Error(
("The field 'f' clashes with the field 'f_id' " "The field 'f' clashes with the field 'f_id' "
"from model 'invalid_models_tests.parent'."), "from model 'invalid_models_tests.parent'.",
hint=None, hint=None,
obj=Child._meta.get_field('f'), obj=Child._meta.get_field('f'),
id='models.E006', id='models.E006',
@ -519,8 +519,8 @@ class ShadowingFieldsTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
("The field 'fk_id' clashes with the field 'fk' from model " "The field 'fk_id' clashes with the field 'fk' from model "
"'invalid_models_tests.model'."), "'invalid_models_tests.model'.",
hint=None, hint=None,
obj=Model._meta.get_field('fk_id'), obj=Model._meta.get_field('fk_id'),
id='models.E006', id='models.E006',
@ -540,7 +540,8 @@ class OtherModelTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
"'id' can only be used as a field name if the field also sets 'primary_key=True'.", "'id' can only be used as a field name if the field also sets "
"'primary_key=True'.",
hint=None, hint=None,
obj=Model, obj=Model,
id='models.E004', id='models.E004',
@ -556,8 +557,8 @@ class OtherModelTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
("'ordering' must be a tuple or list " "'ordering' must be a tuple or list "
"(even if you want to order by only one field)."), "(even if you want to order by only one field).",
hint=None, hint=None,
obj=Model, obj=Model,
id='models.E014', id='models.E014',
@ -662,8 +663,8 @@ class OtherModelTests(IsolatedModelsTestCase):
errors = Model.check() errors = Model.check()
expected = [ expected = [
Error( Error(
("'TEST_SWAPPED_MODEL_BAD_MODEL' references 'not_an_app.Target', " "'TEST_SWAPPED_MODEL_BAD_MODEL' references 'not_an_app.Target', "
'which has not been installed, or is abstract.'), 'which has not been installed, or is abstract.',
hint=None, hint=None,
obj=None, obj=None,
id='models.E002', id='models.E002',
@ -688,8 +689,8 @@ class OtherModelTests(IsolatedModelsTestCase):
errors = Group.check() errors = Group.check()
expected = [ expected = [
Error( Error(
("The model has two many-to-many relations through " "The model has two many-to-many relations through "
"the intermediate model 'invalid_models_tests.Membership'."), "the intermediate model 'invalid_models_tests.Membership'.",
hint=None, hint=None,
obj=Group, obj=Group,
id='models.E003', id='models.E003',