Skip to content

Commit 2bed23b

Browse files
committed
remove pydantic[email]
1 parent b6c2c21 commit 2bed23b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dnspython==2.1.0
2-
email-validator==1.1.3
32
fire==0.4.0
43
idna==3.3
54
pydantic==1.8.2

src/superannotate_schemas/schemas/base.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pydantic import BaseModel as PyDanticBaseModel
77
from pydantic import conlist
88
from pydantic import constr
9-
from pydantic import EmailStr
109
from pydantic import Extra
1110
from pydantic import StrictInt
1211
from pydantic import StrictFloat
@@ -46,6 +45,18 @@ def enum_error_handling(self) -> str:
4645
StrictNumber = Union[StrictInt, StrictFloat]
4746

4847

48+
class EmailStr(StrictStr):
49+
@classmethod
50+
def validate(cls, value: Union[str]) -> Union[str]:
51+
try:
52+
constr(
53+
regex=r"^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
54+
).validate(value)
55+
except StrRegexError:
56+
raise ValueError("Invalid email")
57+
return value
58+
59+
4960
class BaseModel(PyDanticBaseModel):
5061
class Config:
5162
extra = Extra.allow

tests/test_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
from os.path import dirname
44
from tests import LIB_PATH
5-
from pydantic import EmailStr
65

76
from unittest import TestCase
87

0 commit comments

Comments
 (0)