Commit 004ba0f9 authored by Tim Graham's avatar Tim Graham
Browse files

Removed unneeded hint=None/obj=None in system check messages.

parent 36f1f5cf
Loading
Loading
Loading
Loading
+18 −54
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "Both 'fieldsets' and 'fields' are specified.",
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E005',
                )
@@ -133,7 +132,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "The value of 'fields' contains duplicate field(s).",
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E006',
                )
@@ -172,7 +170,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "The value of '%s[1]' must contain the key 'fields'." % label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E011',
                )
@@ -185,7 +182,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "There are duplicate field(s) in '%s[1]'." % label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E012',
                )
@@ -226,10 +222,9 @@ class BaseModelAdminChecks(object):
                        not field.remote_field.through._meta.auto_created):
                    return [
                        checks.Error(
                            ("The value of '%s' cannot include the ManyToManyField '%s', "
                             "because that field manually specifies a relationship model.")
                            "The value of '%s' cannot include the ManyToManyField '%s', "
                            "because that field manually specifies a relationship model."
                            % (label, field_name),
                            hint=None,
                            obj=obj.__class__,
                            id='admin.E013',
                        )
@@ -248,7 +243,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "The value of 'exclude' contains duplicate field(s).",
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E015',
                )
@@ -337,7 +331,6 @@ class BaseModelAdminChecks(object):
                        "instance of ForeignKey, and does not have a 'choices' definition." % (
                            label, field_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E023',
                    )
@@ -354,7 +347,6 @@ class BaseModelAdminChecks(object):
            return [
                checks.Error(
                    "The value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL." % label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E024',
                )
@@ -368,7 +360,6 @@ class BaseModelAdminChecks(object):
                return [
                    checks.Error(
                        "The value of 'view_on_site' must be a callable or a boolean value.",
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E025',
                    )
@@ -414,10 +405,7 @@ class BaseModelAdminChecks(object):
                return [
                    checks.Error(
                        "The value of '%s' refers to '%s', which must not be a DateTimeField, "
                        "ForeignKey or ManyToManyField." % (
                            label, field_name
                        ),
                        hint=None,
                        "ForeignKey or ManyToManyField." % (label, field_name),
                        obj=obj.__class__,
                        id='admin.E028',
                    )
@@ -444,8 +432,7 @@ class BaseModelAdminChecks(object):
        try:
            model._meta.get_field(field_name)
        except FieldDoesNotExist:
            return refer_to_missing_field(field=field_name, option=label,
                                          model=model, obj=obj, id='admin.E030')
            return refer_to_missing_field(field=field_name, option=label, model=model, obj=obj, id='admin.E030')
        else:
            return []

@@ -469,8 +456,8 @@ class BaseModelAdminChecks(object):
        if field_name == '?' and len(obj.ordering) != 1:
            return [
                checks.Error(
                    ("The value of 'ordering' has the random ordering marker '?', "
                     "but contains other fields as well."),
                    "The value of 'ordering' has the random ordering marker '?', "
                    "but contains other fields as well.",
                    hint='Either remove the "?", or remove the other fields.',
                    obj=obj.__class__,
                    id='admin.E032',
@@ -489,8 +476,7 @@ class BaseModelAdminChecks(object):
            try:
                model._meta.get_field(field_name)
            except FieldDoesNotExist:
                return refer_to_missing_field(field=field_name, option=label,
                                              model=model, obj=obj, id='admin.E033')
                return refer_to_missing_field(field=field_name, option=label, model=model, obj=obj, id='admin.E033')
            else:
                return []

@@ -523,7 +509,6 @@ class BaseModelAdminChecks(object):
                        "The value of '%s' is not a callable, an attribute of '%s', or an attribute of '%s.%s'." % (
                            label, obj.__class__.__name__, model._meta.app_label, model._meta.object_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E035',
                    )
@@ -589,7 +574,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
            return [
                checks.Error(
                    "'%s' must inherit from 'BaseModelAdmin'." % inline_label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E104',
                )
@@ -598,14 +582,12 @@ class ModelAdminChecks(BaseModelAdminChecks):
            return [
                checks.Error(
                    "'%s' must have a 'model' attribute." % inline_label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E105',
                )
            ]
        elif not issubclass(inline.model, models.Model):
            return must_be('a Model', option='%s.model' % inline_label,
                           obj=obj, id='admin.E106')
            return must_be('a Model', option='%s.model' % inline_label, obj=obj, id='admin.E106')
        else:
            return inline(model, obj.admin_site).check()

@@ -643,7 +625,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                        "callable, an attribute of '%s', or an attribute or method on '%s.%s'." % (
                            label, item, obj.__class__.__name__, model._meta.app_label, model._meta.object_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E108',
                    )
@@ -652,7 +633,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                return [
                    checks.Error(
                        "The value of '%s' must not be a ManyToManyField." % label,
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E109',
                    )
@@ -671,7 +651,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                        "an attribute of '%s', or an attribute or method on '%s.%s'." % (
                            label, item, obj.__class__.__name__, model._meta.app_label, model._meta.object_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E108',
                    )
@@ -700,7 +679,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                    "The value of '%s' refers to '%s', which is not defined in 'list_display'." % (
                        label, field_name
                    ),
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E111',
                )
@@ -738,7 +716,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                return [
                    checks.Error(
                        "The value of '%s' must not inherit from 'FieldListFilter'." % label,
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E114',
                    )
@@ -749,8 +726,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
            # item is option #2
            field, list_filter_class = item
            if not issubclass(list_filter_class, FieldListFilter):
                return must_inherit_from(parent='FieldListFilter', option='%s[1]' % label,
                                         obj=obj, id='admin.E115')
                return must_inherit_from(parent='FieldListFilter', option='%s[1]' % label, obj=obj, id='admin.E115')
            else:
                return []
        else:
@@ -764,7 +740,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                return [
                    checks.Error(
                        "The value of '%s' refers to '%s', which does not refer to a Field." % (label, field),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E116',
                    )
@@ -776,8 +751,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
        """ Check that list_select_related is a boolean, a list or a tuple. """

        if not isinstance(obj.list_select_related, (bool, list, tuple)):
            return must_be('a boolean, tuple or list', option='list_select_related',
                           obj=obj, id='admin.E117')
            return must_be('a boolean, tuple or list', option='list_select_related', obj=obj, id='admin.E117')
        else:
            return []

@@ -813,15 +787,13 @@ class ModelAdminChecks(BaseModelAdminChecks):
        try:
            field = model._meta.get_field(field_name)
        except FieldDoesNotExist:
            return refer_to_missing_field(field=field_name, option=label,
                                          model=model, obj=obj, id='admin.E121')
            return refer_to_missing_field(field=field_name, option=label, model=model, obj=obj, id='admin.E121')
        else:
            if field_name not in obj.list_display:
                return [
                    checks.Error(
                        "The value of '%s' refers to '%s', which is not "
                        "contained in 'list_display'." % (label, field_name),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E122',
                    )
@@ -830,7 +802,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                return [
                    checks.Error(
                        "The value of '%s' cannot be in both 'list_editable' and 'list_display_links'." % field_name,
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E123',
                    )
@@ -845,7 +816,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                        "which cannot be used unless 'list_display_links' is set." % (
                            label, obj.list_display[0]
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E124',
                    )
@@ -856,7 +826,6 @@ class ModelAdminChecks(BaseModelAdminChecks):
                        "The value of '%s' refers to '%s', which is not editable through the admin." % (
                            label, field_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E125',
                    )
@@ -881,13 +850,13 @@ class ModelAdminChecks(BaseModelAdminChecks):
            try:
                field = obj.model._meta.get_field(obj.date_hierarchy)
            except FieldDoesNotExist:
                return refer_to_missing_field(option='date_hierarchy',
                                              field=obj.date_hierarchy,
                                              model=obj.model, obj=obj, id='admin.E127')
                return refer_to_missing_field(
                    option='date_hierarchy', field=obj.date_hierarchy,
                    model=obj.model, obj=obj, id='admin.E127',
                )
            else:
                if not isinstance(field, (models.DateField, models.DateTimeField)):
                    return must_be('a DateField or DateTimeField', option='date_hierarchy',
                                   obj=obj, id='admin.E128')
                    return must_be('a DateField or DateTimeField', option='date_hierarchy', obj=obj, id='admin.E128')
                else:
                    return []

@@ -927,7 +896,6 @@ class InlineModelAdminChecks(BaseModelAdminChecks):
                    "to the parent model '%s.%s'." % (
                        fk.name, parent_model._meta.app_label, parent_model._meta.object_name
                    ),
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E201',
                )
@@ -939,7 +907,7 @@ class InlineModelAdminChecks(BaseModelAdminChecks):
        try:
            _get_foreign_key(parent_model, obj.model, fk_name=obj.fk_name)
        except ValueError as e:
            return [checks.Error(e.args[0], hint=None, obj=obj.__class__, id='admin.E202')]
            return [checks.Error(e.args[0], obj=obj.__class__, id='admin.E202')]
        else:
            return []

@@ -975,8 +943,7 @@ class InlineModelAdminChecks(BaseModelAdminChecks):
        """ Check formset is a subclass of BaseModelFormSet. """

        if not issubclass(obj.formset, BaseModelFormSet):
            return must_inherit_from(parent='BaseModelFormSet', option='formset',
                                     obj=obj, id='admin.E206')
            return must_inherit_from(parent='BaseModelFormSet', option='formset', obj=obj, id='admin.E206')
        else:
            return []

@@ -985,7 +952,6 @@ def must_be(type, option, obj, id):
    return [
        checks.Error(
            "The value of '%s' must be %s." % (option, type),
            hint=None,
            obj=obj.__class__,
            id=id,
        ),
@@ -996,7 +962,6 @@ def must_inherit_from(parent, option, obj, id):
    return [
        checks.Error(
            "The value of '%s' must inherit from '%s'." % (option, parent),
            hint=None,
            obj=obj.__class__,
            id=id,
        ),
@@ -1009,7 +974,6 @@ def refer_to_missing_field(field, option, model, obj, id):
            "The value of '%s' refers to '%s', which is not an attribute of '%s.%s'." % (
                option, field, model._meta.app_label, model._meta.object_name
            ),
            hint=None,
            obj=obj.__class__,
            id=id,
        ),
+3 −7
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ def check_user_model(app_configs=None, **kwargs):
        errors.append(
            checks.Error(
                "'REQUIRED_FIELDS' must be a list or tuple.",
                hint=None,
                obj=cls,
                id='auth.E001',
            )
@@ -38,9 +37,8 @@ def check_user_model(app_configs=None, **kwargs):
    if cls.USERNAME_FIELD in cls.REQUIRED_FIELDS:
        errors.append(
            checks.Error(
                ("The field named as the 'USERNAME_FIELD' "
                 "for a custom user model must not be included in 'REQUIRED_FIELDS'."),
                hint=None,
                "The field named as the 'USERNAME_FIELD' "
                "for a custom user model must not be included in 'REQUIRED_FIELDS'.",
                obj=cls,
                id='auth.E002',
            )
@@ -55,7 +53,6 @@ def check_user_model(app_configs=None, **kwargs):
                    "'%s.%s' must be unique because it is named as the 'USERNAME_FIELD'." % (
                        cls._meta.object_name, cls.USERNAME_FIELD
                    ),
                    hint=None,
                    obj=cls,
                    id='auth.E003',
                )
@@ -66,8 +63,7 @@ def check_user_model(app_configs=None, **kwargs):
                    "'%s.%s' is named as the 'USERNAME_FIELD', but it is not unique." % (
                        cls._meta.object_name, cls.USERNAME_FIELD
                    ),
                    hint=('Ensure that your authentication backend(s) can handle '
                          'non-unique usernames.'),
                    hint='Ensure that your authentication backend(s) can handle non-unique usernames.',
                    obj=cls,
                    id='auth.W004',
                )
+0 −4
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks):
                    "'%s.%s' has no GenericForeignKey." % (
                        obj.model._meta.app_label, obj.model._meta.object_name
                    ),
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E301'
                )
@@ -48,7 +47,6 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks):
                        "'ct_field' references '%s', which is not a field on '%s.%s'." % (
                            obj.ct_field, obj.model._meta.app_label, obj.model._meta.object_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E302'
                    )
@@ -62,7 +60,6 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks):
                        "'ct_fk_field' references '%s', which is not a field on '%s.%s'." % (
                            obj.ct_fk_field, obj.model._meta.app_label, obj.model._meta.object_name
                        ),
                        hint=None,
                        obj=obj.__class__,
                        id='admin.E303'
                    )
@@ -79,7 +76,6 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks):
                    "'%s.%s' has no GenericForeignKey using content type field '%s' and object ID field '%s'." % (
                        obj.model._meta.app_label, obj.model._meta.object_name, obj.ct_field, obj.ct_fk_field
                    ),
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E304'
                )
+2 −6
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ class GenericForeignKey(object):
            return [
                checks.Error(
                    'Field names must not end with an underscore.',
                    hint=None,
                    obj=self,
                    id='fields.E001',
                )
@@ -107,7 +106,6 @@ class GenericForeignKey(object):
            return [
                checks.Error(
                    "The GenericForeignKey object ID references the non-existent field '%s'." % self.fk_field,
                    hint=None,
                    obj=self,
                    id='contenttypes.E001',
                )
@@ -128,7 +126,6 @@ class GenericForeignKey(object):
                    "The GenericForeignKey content type references the non-existent field '%s.%s'." % (
                        self.model._meta.object_name, self.ct_field
                    ),
                    hint=None,
                    obj=self,
                    id='contenttypes.E002',
                )
@@ -343,11 +340,10 @@ class GenericRelation(ForeignObject):
            else:
                return [
                    checks.Error(
                        ("The GenericRelation defines a relation with the model "
                         "'%s.%s', but that model does not have a GenericForeignKey.") % (
                        "The GenericRelation defines a relation with the model "
                        "'%s.%s', but that model does not have a GenericForeignKey." % (
                            target._meta.app_label, target._meta.object_name
                        ),
                        hint=None,
                        obj=self,
                        id='contenttypes.E004',
                    )
+0 −2
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ class ArrayField(Field):
            errors.append(
                checks.Error(
                    'Base field for array cannot be a related field.',
                    hint=None,
                    obj=self,
                    id='postgres.E002'
                )
@@ -61,7 +60,6 @@ class ArrayField(Field):
                errors.append(
                    checks.Error(
                        'Base field for array has errors:\n    %s' % messages,
                        hint=None,
                        obj=self,
                        id='postgres.E001'
                    )
Loading