Skip to content

Commit 9ea7e27

Browse files
mishagaShagov
and
Shagov
authored
fix pydantic version checking (#80)
Co-authored-by: Shagov <shagov@tochka.com>
1 parent 9a93a17 commit 9ea7e27

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dirty_equals/_other.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def __init__(
229229
self.RedisDsn = RedisDsn
230230
self.parse_obj_as = parse_obj_as
231231
self.ValidationError = ValidationError
232-
self.pydantic_version = version.VERSION
232+
self.pydantic_version = tuple(map(int, version.VERSION.split('.')))
233+
233234
except ImportError as e:
234235
raise ImportError('pydantic is not installed, run `pip install dirty-equals[pydantic]`') from e
235236
url_type_mappings = {
@@ -264,7 +265,11 @@ def equals(self, other: Any) -> bool:
264265
except self.ValidationError:
265266
raise ValueError('Invalid URL')
266267

267-
equal = parsed == other if self.pydantic_version < '2' else parsed.unicode_string() == other
268+
if self.pydantic_version[0] == 1: # checking major version
269+
equal = parsed == other
270+
else:
271+
equal = parsed.unicode_string() == other
272+
268273
if not self.attribute_checks:
269274
return equal
270275

0 commit comments

Comments
 (0)