Repository navigation
Commit 924f477
authored
Declare Struct instance defaults in the type stub (msgspec#1173)
`__struct_defaults__` is available on both Struct classes and instances,
but only the metaclass stub declares it. Access through an instance
therefore fails type checking even though it works at runtime.
Add the missing Struct annotation and cover class and instance access in
the existing typing examples. Runtime behavior is unchanged.
Fixes msgspec#779.
Validation: the new instance assertion fails with mypy, pyright, and
pyrefly before the change; all three typing suites and stubtest pass
afterward. On CPython 3.12, all 6,412 unit tests and 7 package doctests
pass, with 118 skips; the repository's lint, format, and spelling checks
pass. Windows validation used UTF-8 mode for the existing C-source text
checks and a private LLVM-MinGW compiler adapter to build the unchanged
extension. Neither is included in this patch.
Implemented and independently reviewed by automated agents before
submission.1 parent 2c34802 commit 924f477
2 files changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
347 | 348 | | |
348 | 349 | | |
349 | 350 | | |
| |||
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
0 commit comments