Pydantic: UrlStr not available anymore in new pydantic version

Created on 23 Oct 2019  路  5Comments  路  Source: samuelcolvin/pydantic

Bug

In [1]: from pydantic import UrlStr
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-7415c2080b43> in <module>
----> 1 from pydantic import UrlStr

ImportError: cannot import name 'UrlStr' from 'pydantic' (/...../lib/python3.7/site-packages/pydantic/__init__.py)

pydantic version 1.0

Most helpful comment

Breaking Change: complete rewrite of URL parsing logic

Seems a bit short on details, in any event I got the "cannot import name 'UrlStr'" error - hopefully this will help others.
UrlStr has been removed (see https://github.com/samuelcolvin/pydantic/pull/755 for more details). AnyUrl is likely what you should change it to but there's also AnyUrl, AnyHttpUrl, HttpUrl, and HttpsUrl.

All 5 comments

Please read the docs. Including the release notes, three URL types names have changed.

it doesn't show up in the release notes here

Breaking Change: complete rewrite of URL parsing logic

Breaking Change: complete rewrite of URL parsing logic

Seems a bit short on details, in any event I got the "cannot import name 'UrlStr'" error - hopefully this will help others.
UrlStr has been removed (see https://github.com/samuelcolvin/pydantic/pull/755 for more details). AnyUrl is likely what you should change it to but there's also AnyUrl, AnyHttpUrl, HttpUrl, and HttpsUrl.

Hey,

I got caught in that one too. Might I suggest the HISTORY to be a bit clearer when fields are removed? Cheers.

Was this page helpful?
0 / 5 - 0 ratings