Skip to content

Commit

Permalink
Merge branch 'main' into feature/ack-sync-method
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Nov 15, 2024
2 parents 7687e71 + 1c437d7 commit 108d980
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"filename": "docs/docs/en/release.md",
"hashed_secret": "35675e68f4b5af7b995d9205ad0fc43842f16450",
"is_verified": false,
"line_number": 1835,
"line_number": 1850,
"is_secret": false
}
],
Expand All @@ -178,5 +178,5 @@
}
]
},
"generated_at": "2024-11-07T20:55:07Z"
"generated_at": "2024-11-15T07:38:53Z"
}
28 changes: 13 additions & 15 deletions faststream/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
from importlib.metadata import version as get_version
from typing import Any, Callable, Dict, Mapping, Optional, Type, TypeVar, Union

from fast_depends._compat import PYDANTIC_V2 as PYDANTIC_V2
from fast_depends._compat import ( # type: ignore[attr-defined]
PYDANTIC_VERSION as PYDANTIC_VERSION,
)
from pydantic import BaseModel as BaseModel
from pydantic.version import VERSION as PYDANTIC_VERSION

from faststream.types import AnyDict

Expand Down Expand Up @@ -57,23 +54,23 @@ def json_dumps(*a: Any, **kw: Any) -> bytes:

JsonSchemaValue = Mapping[str, Any]

major, minor, *_ = PYDANTIC_VERSION.split(".")
_PYDANTCI_MAJOR, _PYDANTIC_MINOR = int(major), int(minor)

PYDANTIC_V2 = _PYDANTCI_MAJOR >= 2

if PYDANTIC_V2:
if PYDANTIC_VERSION >= "2.4.0":
if _PYDANTIC_MINOR >= 4:
from pydantic.annotated_handlers import (
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
from pydantic_core.core_schema import (
with_info_plain_validator_function as with_info_plain_validator_function,
)
else:
if PYDANTIC_VERSION >= "2.10":
from pydantic.annotated_handlers import (
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
else:
from pydantic._internal._annotated_handlers import ( # type: ignore[no-redef]
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
from pydantic._internal._annotated_handlers import ( # type: ignore[no-redef]
GetJsonSchemaHandler as GetJsonSchemaHandler,
)
from pydantic_core.core_schema import (
general_plain_validator_function as with_info_plain_validator_function,
)
Expand Down Expand Up @@ -155,8 +152,9 @@ def with_info_plain_validator_function( # type: ignore[misc]
return {}


anyio_major = int(get_version("anyio").split(".")[0])
ANYIO_V3 = anyio_major == 3
major, *_ = get_version("anyio").split(".")
_ANYIO_MAJOR = int(major)
ANYIO_V3 = _ANYIO_MAJOR == 3


if ANYIO_V3:
Expand Down
28 changes: 23 additions & 5 deletions faststream/broker/fastapi/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,29 @@
from fastapi.dependencies.models import Dependant
from fastapi.requests import Request

major, minor, patch, *_ = map(int, FASTAPI_VERSION.split("."))
FASTAPI_V2 = major > 0 or minor > 100
FASTAPI_V106 = major > 0 or minor >= 106
FASTAPI_v102_3 = major > 0 or minor > 112 or (minor == 112 and patch > 2)
FASTAPI_v102_4 = major > 0 or minor > 112 or (minor == 112 and patch > 3)
major, minor, patch, *_ = FASTAPI_VERSION.split(".")

_FASTAPI_MAJOR, _FASTAPI_MINOR = int(major), int(minor)

FASTAPI_V2 = _FASTAPI_MAJOR > 0 or _FASTAPI_MINOR > 100
FASTAPI_V106 = _FASTAPI_MAJOR > 0 or _FASTAPI_MINOR >= 106

try:
_FASTAPI_PATCH = int(patch)
except ValueError:
FASTAPI_v102_3 = True
FASTAPI_v102_4 = True
else:
FASTAPI_v102_3 = (
_FASTAPI_MAJOR > 0
or _FASTAPI_MINOR > 112
or (_FASTAPI_MINOR == 112 and _FASTAPI_PATCH > 2)
)
FASTAPI_v102_4 = (
_FASTAPI_MAJOR > 0
or _FASTAPI_MINOR > 112
or (_FASTAPI_MINOR == 112 and _FASTAPI_PATCH > 3)
)

__all__ = (
"create_response_field",
Expand Down
4 changes: 2 additions & 2 deletions faststream/nats/broker/registrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def subscriber( # type: ignore[override]
Doc("Enable Heartbeats for a consumer to detect failures."),
] = None,
flow_control: Annotated[
bool,
Optional[bool],
Doc("Enable Flow Control for a consumer."),
] = False,
] = None,
deliver_policy: Annotated[
Optional["api.DeliverPolicy"],
Doc("Deliver Policy to be used for subscription."),
Expand Down
4 changes: 2 additions & 2 deletions faststream/nats/fastapi/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ def subscriber( # type: ignore[override]
Doc("Enable Heartbeats for a consumer to detect failures."),
] = None,
flow_control: Annotated[
bool,
Optional[bool],
Doc("Enable Flow Control for a consumer."),
] = False,
] = None,
deliver_policy: Annotated[
Optional["api.DeliverPolicy"],
Doc("Deliver Policy to be used for subscription."),
Expand Down
4 changes: 2 additions & 2 deletions faststream/nats/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def __init__(
Doc("Enable Heartbeats for a consumer to detect failures."),
] = None,
flow_control: Annotated[
bool,
Optional[bool],
Doc("Enable Flow Control for a consumer."),
] = False,
] = None,
deliver_policy: Annotated[
Optional["api.DeliverPolicy"],
Doc("Deliver Policy to be used for subscription."),
Expand Down
Loading

0 comments on commit 108d980

Please sign in to comment.