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

Export UUID in the compat module #43

Merged
merged 1 commit into from
May 3, 2024
Merged

Export UUID in the compat module #43

merged 1 commit into from
May 3, 2024

Conversation

angelsenra
Copy link
Contributor

@angelsenra angelsenra commented Apr 30, 2024

First of all thank you for this great package.

I had an issue at first when trying to use this with pydantic:

pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'uuid_utils.UUID'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.

For further information visit https://errors.pydantic.dev/2.7/u/schema-for-unknown-type

I was going to suggest adding support for __get_pydantic_core_schema__ but then I saw #32 and thought it best to just use the compat version.

However, the compat package doesn't export UUID like the normal one. That's what this PR adds. So one can do import uuid_utils.compat as uuid and act as if it was the built-in uuid.

There are other exports in the main __all__ that are also missing (namespaces, reserved, and getnode). Those I've never used but I would see the point in exporting the exact same list.

Export UUID so one can `import uuid_utils.compat as uuid`
Copy link
Owner

@aminalaee aminalaee 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 PR

@aminalaee aminalaee merged commit 3b0e935 into aminalaee:main May 3, 2024
15 checks passed
@aminalaee aminalaee mentioned this pull request May 3, 2024
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.

2 participants