File tree Expand file tree Collapse file tree 3 files changed +5
-32
lines changed
Expand file tree Collapse file tree 3 files changed +5
-32
lines changed Original file line number Diff line number Diff line change 33from benedict .extras import require_validate
44
55try :
6- from pydantic .v2 import BaseModel
7- from pydantic .v2 .json import pydantic_encoder
6+ from pydantic import BaseModel
87
98 pydantic_installed = True
109except ImportError :
1110 pydantic_installed = False
1211 BaseModel = None
13- pydantic_encoder = None
1412
1513PydanticModel = type ["BaseModel" ]
1614
1715
18- def is_pydantic_model (obj : Any ) -> bool :
19- """
20- Check if an object is a Pydantic model.
21- """
22- return pydantic_installed and isinstance (obj , BaseModel )
23-
24-
2516def is_pydantic_model_class (obj : Any ) -> bool :
2617 """
2718 Check if an object is a Pydantic model class.
Original file line number Diff line number Diff line change 11import json
22import unittest
33
4- from benedict import benedict
5-
6- try :
7- from pydantic .v2 import BaseModel
8- from pydantic .v2 .errors import ValidationError
4+ from pydantic import BaseModel , ValidationError
95
10- pydantic_installed = True
11- except ImportError :
12- pydantic_installed = False
13- BaseModel = None
14- ValidationError = None
6+ from benedict import benedict
157
168
17- @unittest .skipIf (not pydantic_installed , "pydantic not installed" )
189class TestIODictSchema (unittest .TestCase ):
1910 def setUp (self ):
2011 class User (BaseModel ):
Original file line number Diff line number Diff line change 11import unittest
22
3- from benedict .dicts .io import IODict
4-
5- try :
6- from pydantic .v2 import BaseModel
7- from pydantic .v2 .errors import ValidationError
3+ from pydantic import BaseModel , ValidationError
84
9- pydantic_installed = True
10- except ImportError :
11- pydantic_installed = False
12- BaseModel = None
13- ValidationError = None
5+ from benedict .dicts .io import IODict
146
157
16- @unittest .skipIf (not pydantic_installed , "pydantic not installed" )
178class TestIODictValidate (unittest .TestCase ):
189 def setUp (self ):
1910 class User (BaseModel ):
You can’t perform that action at this time.
0 commit comments