Commit a1dd86b
temp: report FEATURES-as-dict warning at the real caller
Pushed standalone first so CI surfaces the full list of caller
sites before the migration commits land.
FeaturesProxy.__setitem__ used stacklevel=2 and update() delegated
to __setitem__, so every warning was reported at update()'s own
'self[key] = other[key]' line in this file (89) instead of the
test or app code that actually mutated FEATURES.
Why the helper instead of just bumping stacklevel: stacklevel is
a frame count from warnings.warn upward. Bumping __setitem__'s
stacklevel from 2 to 3 would fix the update()->__setitem__ path
but would overshoot by one frame on direct __setitem__ calls
(e.g. fp['X'] = True), reporting from the caller's caller. The
two paths need different stacklevel arithmetic.
Factors the emit into _warn_dict_access(stacklevel=3) so both
__setitem__ and update() can call it with the same constant; each
contributes exactly one intermediate frame. update() now writes to
self.ns directly to avoid double-warning. No behavior change
beyond the reported source location.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 20636c5 commit a1dd86b
1 file changed
Lines changed: 33 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
62 | 76 | | |
63 | 77 | | |
64 | | - | |
| 78 | + | |
| 79 | + | |
65 | 80 | | |
66 | | - | |
| 81 | + | |
67 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
68 | 87 | | |
69 | 88 | | |
70 | 89 | | |
| |||
114 | 133 | | |
115 | 134 | | |
116 | 135 | | |
| 136 | + | |
| 137 | + | |
117 | 138 | | |
118 | 139 | | |
119 | 140 | | |
120 | 141 | | |
121 | | - | |
| 142 | + | |
| 143 | + | |
122 | 144 | | |
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
126 | | - | |
| 148 | + | |
| 149 | + | |
127 | 150 | | |
128 | 151 | | |
129 | | - | |
| 152 | + | |
| 153 | + | |
130 | 154 | | |
131 | | - | |
| 155 | + | |
| 156 | + | |
132 | 157 | | |
133 | 158 | | |
134 | 159 | | |
| |||
0 commit comments