Skip to content

Commit e8cbcaa

Browse files
mgorvenfelipao-mx
andauthored
Allow clabe to be used in Pydantic V2 codebases (#167)
* Allow clabe to be used in Pydantic V2 codebases clabe uses Pydantic V1 and currently can't be used in a codebase which already uses Pydantic V2. Implement the compatibility approach described in https://docs.pydantic.dev/latest/migration/#using-pydantic-v1-features-in-a-v1v2-environment Pydantic is upgraded to `>=1.10.17` and imports are changed to the `pydantic.v1` namespace. This allows clabe to be used with either Pydantic V1 or V2. Bump version to 1.2.17. * bump version --------- Co-authored-by: Felipe López <flh.1989@gmail.com>
1 parent cd31bec commit e8cbcaa

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

clabe/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic.errors import PydanticValueError
1+
from pydantic.v1.errors import PydanticValueError
22

33

44
class BankCodeValidationError(PydanticValueError):

clabe/types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING, ClassVar
22

3-
from pydantic.errors import NotDigitError
4-
from pydantic.validators import (
3+
from pydantic.v1.errors import NotDigitError
4+
from pydantic.v1.validators import (
55
constr_length_validator,
66
constr_strip_whitespace,
77
str_validator,
@@ -11,7 +11,7 @@
1111
from .validations import BANK_NAMES, BANKS, compute_control_digit
1212

1313
if TYPE_CHECKING:
14-
from pydantic.typing import CallableGenerator
14+
from pydantic.v1.typing import CallableGenerator
1515

1616

1717
def validate_digits(v: str) -> str:

clabe/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.2.17'
1+
__version__ = '1.3.0'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pydantic==1.9.0
1+
pydantic==1.10.19

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
packages=setuptools.find_packages(),
2222
include_package_data=True,
2323
package_data=dict(clabe=['py.typed']),
24-
install_requires=['pydantic>=1.4,<2.0'],
24+
install_requires=['pydantic>=1.10.17'],
2525
classifiers=[
2626
'Programming Language :: Python :: 3',
2727
'License :: OSI Approved :: MIT License',

tests/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
2-
from pydantic import BaseModel
3-
from pydantic.errors import NotDigitError
2+
from pydantic.v1 import BaseModel
3+
from pydantic.v1.errors import NotDigitError
44

55
from clabe import BANK_NAMES, BANKS, compute_control_digit
66
from clabe.errors import (

0 commit comments

Comments
 (0)