Commit 38e0483
Tidy _check_monitoring_location_id (clearer dispatch, helper, type hints)
Internal refactor; behavior unchanged.
- Add full type hints: ``str | Iterable[str] | None`` in,
``str | list[str] | None`` out, mirroring the runtime contract.
- Split into explicit fast paths instead of wrapping-then-unwrapping:
the string case validates and returns directly, eliminating the
throwaway ``[monitoring_location_id]`` list and the final
``isinstance(str)`` re-check at return.
- Invert the Mapping/Iterable check: reject ``Mapping`` (and non-iterables)
up front, then ``list()`` the iterable. Reads more linearly than the
compound ``isinstance(Iterable) and not isinstance(Mapping)``.
- Extract ``_check_id_format(value)`` for the regex/ValueError pair so
the format rule lives in one place and the call sites are one-liners.
Tests unchanged; 16 validator tests + full suite still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fa8387e commit 38e0483
1 file changed
Lines changed: 29 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
1159 | | - | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1160 | 1162 | | |
1161 | 1163 | | |
1162 | 1164 | | |
1163 | 1165 | | |
1164 | 1166 | | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
1170 | 1172 | | |
1171 | 1173 | | |
1172 | 1174 | | |
1173 | 1175 | | |
1174 | | - | |
1175 | | - | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1176 | 1179 | | |
1177 | 1180 | | |
1178 | 1181 | | |
1179 | 1182 | | |
1180 | | - | |
1181 | | - | |
| 1183 | + | |
| 1184 | + | |
1182 | 1185 | | |
1183 | 1186 | | |
1184 | 1187 | | |
| |||
1187 | 1190 | | |
1188 | 1191 | | |
1189 | 1192 | | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1193 | 1198 | | |
1194 | | - | |
1195 | | - | |
1196 | 1199 | | |
1197 | 1200 | | |
1198 | 1201 | | |
1199 | 1202 | | |
1200 | 1203 | | |
1201 | 1204 | | |
| 1205 | + | |
1202 | 1206 | | |
1203 | 1207 | | |
1204 | 1208 | | |
1205 | 1209 | | |
1206 | 1210 | | |
1207 | 1211 | | |
1208 | 1212 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
| 1213 | + | |
| 1214 | + | |
1214 | 1215 | | |
1215 | | - | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1216 | 1224 | | |
1217 | 1225 | | |
1218 | 1226 | | |
| |||
0 commit comments