#23750: django.core.checks.register shouldn't be (primarily) a decorator
------------------------------------------------+------------------------
Reporter: shaib | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (System checks) | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
`django.core.checks.register` is commonly used as a function, called from
`AppConfig.ready()`, and not as a
decorator; but it is defined as a decorator, so it looks a little funny:
{{{
checks.register('models')(check_generic_foreign_keys)
}}}
(from the contenttypes AppConfig, for example).
Registering checks only in ready(), rather than at import time, is now the
way
to do things, so register() should typically not be used as a decorator; I
think we should change its definition accordingly, to
{{{
def register(self, check, *tags)
}}}
-----
The above is, essentially, an old [https://groups.google.com/forum/#!msg
/django-developers/jfnzeOnyBSU/FBc9i8iMc8oJ message] of mine to django-
developers; in that thread, you can find Russell agreeing, and Marc adding
that the checks documentation needs to change as well. However, since 1.7
was already released, `register` needs to be changed in a backwards-
compatible way -- so that it can be used either as it is currently, or
using the more natural style.
--
Ticket URL: <https://code.djangoproject.com/ticket/23750>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.b8f44da1966ac697d4c4b677501f3bbc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.