mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
24 lines
473 B
Python
24 lines
473 B
Python
from __future__ import annotations
|
|
from pydantic import BaseModel
|
|
from pydantic.errors import PydanticUserError
|
|
|
|
|
|
def this_is_broken():
|
|
from pydantic import HttpUrl # HttpUrl is defined in function local scope
|
|
|
|
class Model(BaseModel):
|
|
a: HttpUrl
|
|
|
|
try:
|
|
Model(a='https://example.com')
|
|
except PydanticUserError as e:
|
|
print(e)
|
|
|
|
try:
|
|
Model.update_forward_refs()
|
|
except NameError as e:
|
|
print(e)
|
|
|
|
|
|
this_is_broken()
|