Commit b183f2a
committed
Recognize plain aliases of an existing sentinel as sentinel declarations
Currently `is_sentinel_declaration` only recognizes the exact `NAME = Sentinel("NAME")` call shape, so a re-export like `ALIAS = NAME` (same module or via `import mod; ALIAS = mod.NAME`) silently loses is_sentinel, and ALIAS becomes invalid in type position.
This is exactly the pattern pydantic 2.14 uses to re-export MISSING from pydantic_core: `MISSING = pydantic_core.MISSING`.
Extend is_sentinel_declaration/setup_sentinel_var to also accept a `RefExpr` rvalue (`NameExpr` or `MemberExpr`) that resolves to a Var already flagged `is_sentinel`, reusing its already-computed `LiteralType` rather than requiring a fresh `Sentinel(...)` call.
Signed-off-by: Edgar Ramírez Mondragón <[email protected]>1 parent ab3849b commit b183f2a
2 files changed
Lines changed: 42 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3406 | 3406 | | |
3407 | 3407 | | |
3408 | 3408 | | |
3409 | | - | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
3410 | 3416 | | |
3411 | 3417 | | |
3412 | 3418 | | |
3413 | 3419 | | |
| 3420 | + | |
| 3421 | + | |
3414 | 3422 | | |
3415 | 3423 | | |
3416 | 3424 | | |
| |||
3430 | 3438 | | |
3431 | 3439 | | |
3432 | 3440 | | |
3433 | | - | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
3434 | 3448 | | |
3435 | 3449 | | |
3436 | 3450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 193 | + | |
| 194 | + | |
196 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
197 | 219 | | |
198 | 220 | | |
199 | 221 | | |
| |||
0 commit comments