Skip to content

fix inspection for structs that use the StructMeta metaclass (#941) - #945

Merged
ofek merged 6 commits into
msgspec:mainfrom
provinzkraut:fix-inspect-struct-meta
Nov 23, 2025
Merged

fix inspection for structs that use the StructMeta metaclass (#941)#945
ofek merged 6 commits into
msgspec:mainfrom
provinzkraut:fix-inspect-struct-meta

Conversation

@provinzkraut

Copy link
Copy Markdown
Member

Allow msgspec.structs.field on types that use metaclass=StructMeta.

Fixes #941.

@ofek

ofek commented Nov 21, 2025

Copy link
Copy Markdown
Member

Thanks! Have you confirmed that this also fixes the second comment in that issue? It appears to be a different error.

@provinzkraut

Copy link
Copy Markdown
Member Author

Ah, I didn't see that a second comment was added! I'll take a look at this as well and update this PR

@ofek

ofek commented Nov 21, 2025

Copy link
Copy Markdown
Member

Do you have an estimate on when you might be able to check? I was planning on releasing in a few hours.

@provinzkraut

Copy link
Copy Markdown
Member Author

I've fixed inspect.type_info. asdict did work as expected already.

@ofek

ofek commented Nov 22, 2025

Copy link
Copy Markdown
Member

I added another test to confirm the expected behavior!

@provinzkraut

Copy link
Copy Markdown
Member Author

@ofek seems like that test you added uncovered another case that was still buggy. I've pushed an additional fix for that.

I've got the feeling though that there might still have some cases left elsewhere in the library where StructMeta isn't handled as expected 👀

@ofek

ofek commented Nov 23, 2025

Copy link
Copy Markdown
Member

I pushed some code changes and a doc update. What we want to express in the type system currently is not possible, example discussion in python/typing#1489.

@ofek ofek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for taking the initiative here!

@ofek
ofek merged commit b1266b1 into msgspec:main Nov 23, 2025
23 checks passed
@provinzkraut
provinzkraut deleted the fix-inspect-struct-meta branch November 25, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot do inspection when using StructMeta

2 participants