Opened 9 months ago

Closed 9 months ago

#35231 closed New feature (wontfix)

Add system checks for settings types

Reported by: Alexander Lazarević Owned by: Alexander Lazarević
Component: Core (Other) Version: dev
Severity: Normal Keywords: systemchecks
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The discussion about this can be found on the forum at: https://forum.djangoproject.com/t/make-the-system-check-look-at-the-types-of-settings/27424

Use system checks to look for sane setting types at the start. Output would be something like this:

System check identified some issues:

WARNINGS:
?: (files.W001) The type of CACHE_MIDDLEWARE_SECONDS should be int (default 600). see https://docs.djangoproject.com/en/dev/ref/settings/#std-setting-CACHE_MIDDLEWARE_SECONDS

For some misconfigured settings there will still be an explicit ImproperlyConfigured exception raised (like The ALLOWED_HOSTS setting must be a list or a tuple) or an implicit exception like AttributeError: ‘int’ object has no attribute ‘find’ when for example set LANGUAGE_CODE to an int.

The implementation checks the type of the default value against the type of the user setting and issues a warning if they don’t match. This works for most settings, since they do have a default value other than None. For the ones that have None as the default value, a table is present, that contains the expected default values.

Change History (2)

comment:1 by Alexander Lazarević, 9 months ago

Owner: changed from nobody to Alexander Lazarević
Status: newassigned

comment:2 by Mariusz Felisiak, 9 months ago

Resolution: wontfix
Status: assignedclosed

Closing as "wontfix" as we haven't reached a consensus on the forum (at least for now).

Note: See TracTickets for help on using tickets.
Back to Top