Commit 1299ef1
feat: bridge FEATURES proxy reads to @override_settings overrides
Lets @override_settings(KEY=val) be seen through both settings.KEY
and settings.FEATURES['KEY']/.get('KEY'), so tests can migrate to
the flat setting without first updating every production reader
that still does settings.FEATURES['KEY'].
We walk only the UserSettingsHolder chain that @override_settings
pushes onto django.conf.settings._wrapped, NOT the bottom Settings
layer. Django's bottom Settings is a *snapshot* of the settings
module's globals taken at init time, so it doesn't reflect runtime
mutations of the module's globals — which is exactly what legacy
patch.dict(settings.FEATURES, ...) does via proxy.ns. Reading the
snapshot would mask those mutations and break legacy tests; walking
only the explicit override layers lets both paths coexist during
the migration.
ns kept as-is. A stateless redesign (drop ns, route everything
through django.conf.settings, set FEATURES = FeaturesProxy() in
each env file) was considered but rejected for this step because
FEATURES.copy() and __iter__ are widely used to snapshot the full
set of feature flags; without ns there is no clean source of truth
for "which keys are features". Once all callers have moved off the
dict pattern the proxy can be deleted outright (every
settings.FEATURES['X'] becomes settings.X), making the stateless
refactor unnecessary.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f999886 commit 1299ef1
1 file changed
Lines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
27 | 53 | | |
28 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
29 | 58 | | |
30 | 59 | | |
31 | 60 | | |
| |||
49 | 78 | | |
50 | 79 | | |
51 | 80 | | |
52 | | - | |
| 81 | + | |
53 | 82 | | |
54 | 83 | | |
55 | 84 | | |
56 | 85 | | |
57 | 86 | | |
58 | 87 | | |
59 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
60 | 92 | | |
61 | 93 | | |
62 | 94 | | |
| |||
0 commit comments