File tree 1 file changed +21
-12
lines changed
1 file changed +21
-12
lines changed Original file line number Diff line number Diff line change 12
12
# License for the specific language governing permissions and limitations
13
13
# under the License.
14
14
15
+ from typing import TYPE_CHECKING
16
+
15
17
from cloudevents .exceptions import PydanticFeatureNotInstalled
16
18
17
19
try :
18
- from pydantic import VERSION as PYDANTIC_VERSION
19
-
20
- pydantic_major_version = PYDANTIC_VERSION .split ("." )[0 ]
21
- if pydantic_major_version == "1" :
22
- from cloudevents .pydantic .v1 import CloudEvent , from_dict , from_http , from_json
23
-
20
+ if TYPE_CHECKING :
21
+ from cloudevents .pydantic .v2 import CloudEvent , from_dict , from_http , from_json
24
22
else :
25
- from cloudevents .pydantic .v2 import ( # type: ignore
26
- CloudEvent ,
27
- from_dict ,
28
- from_http ,
29
- from_json ,
30
- )
23
+ from pydantic import VERSION as PYDANTIC_VERSION
24
+
25
+ pydantic_major_version = PYDANTIC_VERSION .split ("." )[0 ]
26
+ if pydantic_major_version == "1" :
27
+ from cloudevents .pydantic .v1 import (
28
+ CloudEvent ,
29
+ from_dict ,
30
+ from_http ,
31
+ from_json ,
32
+ )
33
+ else :
34
+ from cloudevents .pydantic .v2 import (
35
+ CloudEvent ,
36
+ from_dict ,
37
+ from_http ,
38
+ from_json ,
39
+ )
31
40
32
41
except ImportError : # pragma: no cover # hard to test
33
42
raise PydanticFeatureNotInstalled (
You can’t perform that action at this time.
0 commit comments