Skip to content

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

Merged
ofek merged 6 commits intojcrist: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 intojcrist:mainfrom
provinzkraut:fix-inspect-struct-meta

Conversation

@provinzkraut
Copy link
Copy Markdown
Contributor

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

Fixes #941.

@ofek
Copy link
Copy Markdown
Collaborator

ofek commented Nov 21, 2025

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
Contributor 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
Copy link
Copy Markdown
Collaborator

ofek commented Nov 21, 2025

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
Contributor Author

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

@ofek
Copy link
Copy Markdown
Collaborator

ofek commented Nov 22, 2025

I added another test to confirm the expected behavior!

@provinzkraut
Copy link
Copy Markdown
Contributor 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
Copy link
Copy Markdown
Collaborator

ofek commented Nov 23, 2025

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.

Copy link
Copy Markdown
Collaborator

@ofek ofek left a comment

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 jcrist: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