|
4 | 4 | from importlib.metadata import version as get_version
|
5 | 5 | from typing import Any, Callable, Dict, Mapping, Optional, Type, TypeVar, Union
|
6 | 6 |
|
7 |
| -from fast_depends._compat import PYDANTIC_V2 as PYDANTIC_V2 |
8 |
| -from fast_depends._compat import ( # type: ignore[attr-defined] |
9 |
| - PYDANTIC_VERSION as PYDANTIC_VERSION, |
10 |
| -) |
11 | 7 | from pydantic import BaseModel as BaseModel
|
| 8 | +from pydantic.version import VERSION as PYDANTIC_VERSION |
12 | 9 |
|
13 | 10 | from faststream.types import AnyDict
|
14 | 11 |
|
@@ -57,23 +54,23 @@ def json_dumps(*a: Any, **kw: Any) -> bytes:
|
57 | 54 |
|
58 | 55 | JsonSchemaValue = Mapping[str, Any]
|
59 | 56 |
|
| 57 | +major, minor, *_ = PYDANTIC_VERSION.split(".") |
| 58 | +_PYDANTCI_MAJOR, _PYDANTIC_MINOR = int(major), int(minor) |
| 59 | + |
| 60 | +PYDANTIC_V2 = _PYDANTCI_MAJOR >= 2 |
| 61 | + |
60 | 62 | if PYDANTIC_V2:
|
61 |
| - if PYDANTIC_VERSION >= "2.4.0": |
| 63 | + if _PYDANTIC_MINOR >= 4: |
62 | 64 | from pydantic.annotated_handlers import (
|
63 | 65 | GetJsonSchemaHandler as GetJsonSchemaHandler,
|
64 | 66 | )
|
65 | 67 | from pydantic_core.core_schema import (
|
66 | 68 | with_info_plain_validator_function as with_info_plain_validator_function,
|
67 | 69 | )
|
68 | 70 | else:
|
69 |
| - if PYDANTIC_VERSION >= "2.10": |
70 |
| - from pydantic.annotated_handlers import ( |
71 |
| - GetJsonSchemaHandler as GetJsonSchemaHandler, |
72 |
| - ) |
73 |
| - else: |
74 |
| - from pydantic._internal._annotated_handlers import ( # type: ignore[no-redef] |
75 |
| - GetJsonSchemaHandler as GetJsonSchemaHandler, |
76 |
| - ) |
| 71 | + from pydantic._internal._annotated_handlers import ( # type: ignore[no-redef] |
| 72 | + GetJsonSchemaHandler as GetJsonSchemaHandler, |
| 73 | + ) |
77 | 74 | from pydantic_core.core_schema import (
|
78 | 75 | general_plain_validator_function as with_info_plain_validator_function,
|
79 | 76 | )
|
@@ -155,8 +152,9 @@ def with_info_plain_validator_function( # type: ignore[misc]
|
155 | 152 | return {}
|
156 | 153 |
|
157 | 154 |
|
158 |
| -anyio_major = int(get_version("anyio").split(".")[0]) |
159 |
| -ANYIO_V3 = anyio_major == 3 |
| 155 | +major, *_ = get_version("anyio").split(".") |
| 156 | +_ANYIO_MAJOR = int(major) |
| 157 | +ANYIO_V3 = _ANYIO_MAJOR == 3 |
160 | 158 |
|
161 | 159 |
|
162 | 160 | if ANYIO_V3:
|
|
0 commit comments