Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle where Annotated has unhashable metadata. #566

Merged

Conversation

peterschutt
Copy link
Contributor

This PR handles the case where t in the call to _CONCRETE_TYPES.get(t) is not hashable, such as when an Annotated instance contains unhashable metadata.

Closes #565

Copy link
Owner

@jcrist jcrist left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Also - are you using msgspec.inspect.type_info directly? If so, you might be better served by using msgspec.structs.fields instead. This gets you the field information about a struct type without recursively converting all subfields into structured types. For most use cases msgspec.structs.fields is probably what you want.

@jcrist jcrist merged commit 260dfbc into jcrist:main Oct 11, 2023
8 checks passed
@peterschutt
Copy link
Contributor Author

Thanks for the fix!

Also - are you using msgspec.inspect.type_info directly? If so, you might be better served by using msgspec.structs.fields instead. This gets you the field information about a struct type without recursively converting all subfields into structured types. For most use cases msgspec.structs.fields is probably what you want.

Thanks for the tip! I'll review.

peterschutt added a commit to litestar-org/litestar that referenced this pull request Oct 11, 2023
…fields()`.

As suggested [here](jcrist/msgspec#566 (review)), the `type_info()` function is overkill for this application.
@peterschutt peterschutt deleted the 565-inspect-type-info-unhashable-metadata branch October 11, 2023 22:45
peterschutt added a commit to litestar-org/litestar that referenced this pull request Oct 12, 2023
….fields()` (#2424)

refactor: replace `msgspec.inspect.type_info() with `msgspec.structs.fields()`.

As suggested [here](jcrist/msgspec#566 (review)), the `type_info()` function is overkill for this application.
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.

TypeError from inspect.type_info with unhashable Annotated metadata
2 participants