Skip to content

Commit 9741cf9

Browse files
committed
Fix imports and code cleanup.
1 parent 1446816 commit 9741cf9

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

benedict/utils/pydantic_util.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,16 @@
33
from benedict.extras import require_validate
44

55
try:
6-
from pydantic.v2 import BaseModel
7-
from pydantic.v2.json import pydantic_encoder
6+
from pydantic import BaseModel
87

98
pydantic_installed = True
109
except ImportError:
1110
pydantic_installed = False
1211
BaseModel = None
13-
pydantic_encoder = None
1412

1513
PydanticModel = 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-
2516
def is_pydantic_model_class(obj: Any) -> bool:
2617
"""
2718
Check if an object is a Pydantic model class.

tests/dicts/io/test_io_dict_schema.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import json
22
import 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")
189
class TestIODictSchema(unittest.TestCase):
1910
def setUp(self):
2011
class User(BaseModel):

tests/dicts/io/test_io_dict_validate.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import 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")
178
class TestIODictValidate(unittest.TestCase):
189
def setUp(self):
1910
class User(BaseModel):

0 commit comments

Comments
 (0)