Pydantic URL types that are based on the str class.
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install pydantic-string-urlpydantic-string-url
Pydantic URL types that are based on the str class.
Introduction
Since Pydantic v2 the types realated to
URLs are not based on the
standard Python str class any more.
This decision comes with some issues:
- URLs cannot be directly passed to library packages that expect
str, you must usestr(url)instead - some internal normalization is done, so the input strings are not always preserved when a URL object is created (trailing slashes could be added), which might be problematic for some applications
This package provides direct replacements for the Pydantic types:
AnyUrlAnyHttpUrlHttpUrlAnyWebsocketUrlWebsocketUrlFileUrlFtpUrl
Those replacement types are based on strings, so they are also a str, preserve the original input
string and use the same validation functions as their Pydantic counterparts.
You can still use the replacement type's .url property to access the original Pydantic URL type.
See also the discussions here: