v0.1.1 - URL Validation and Typing Improvements
Refactor: URL Validation and Typing Improvements
This release overhauls the handling and validation of URL fields to align with msgspec 0.19.0 capabilities and improve robustness.
Key Changes:
- feat(validation): Switched URL validation from a custom
URLclass and converter to usingtyping.Annotated[str, msgspec.Meta(pattern=URL_PATTERN)]. This leveragesmsgspec's built-in, efficient pattern matching for validation. - fix(generator): Updated the code generation logic (
generate.py) to correctly include necessary imports (typing.Annotated,msgspec.Meta) when generating models with URL fields. - fix(mapping): Updated the internal Schema.org-to-Python type mapping (
mapping.py) to reflect the newAnnotatedapproach for URLs. - test: Added a new test suite (
test_url_validation.py) specifically for verifying the URL regex pattern and the validation behavior withinmsgspec.Structs. - test: Refactored existing tests that were skipped or failing due to the previous incompatible URL validation method. All tests now pass.
- docs: Updated
README.mdto accurately describe the pattern-based URL validation mechanism and remove references to the old converter method.
Notes:
This refactor resolves the incompatibility issues encountered with the previous URL validation approach in msgspec v0.19.0. The new method is more idiomatic, performant, and directly uses msgspec's intended validation features.