Skip to content

Commit

Permalink
Merge branch '0.6.0' into refactor/new-asyncapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik authored Oct 17, 2024
2 parents a81be9c + aa6dc13 commit 77905ff
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 48 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/pr_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
pydantic-version: ["pydantic-v1", "pydantic-v2"]
fail-fast: false

Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand All @@ -124,7 +124,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand All @@ -143,7 +143,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -339,7 +339,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -367,7 +367,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -397,7 +397,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -425,7 +425,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down
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": 1723,
"line_number": 1756,
"is_secret": false
}
],
Expand All @@ -178,5 +178,5 @@
}
]
},
"generated_at": "2024-09-25T19:57:57Z"
"generated_at": "2024-10-15T04:48:28Z"
}
2 changes: 1 addition & 1 deletion docs/docs/en/getting-started/integrations/fastapi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Just import a **StreamRouter** you need and declare the message handler in the s
{! includes/getting_started/integrations/fastapi/1.md !}

!!! warning
If you are using **fastapi < 0.102.2** version, you should setup lifespan manually `#!python FastAPI(lifespan=router.lifespan_context)`
If you are using **fastapi < 0.112.2** version, you should setup lifespan manually `#!python FastAPI(lifespan=router.lifespan_context)`

When processing a message from a broker, the entire message body is placed simultaneously in both the `body` and `path` request parameters. You can access them in any way convenient for you. The message header is placed in `headers`.

Expand Down
32 changes: 32 additions & 0 deletions docs/docs/en/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@ hide:
---

# Release Notes
## 0.5.27

### What's Changed

* fix: anyio major version parser by [@dotX12](https://github.com/dotX12){.external-link target="_blank"} in [#1850](https://github.com/airtai/faststream/pull/1850){.external-link target="_blank"}

### New Contributors
* [@dotX12](https://github.com/dotX12){.external-link target="_blank"} made their first contribution in [#1850](https://github.com/airtai/faststream/pull/1850){.external-link target="_blank"}

**Full Changelog**: [#0.5.26...0.5.27](https://github.com/airtai/faststream/compare/0.5.26...0.5.27){.external-link target="_blank"}

## 0.5.26

### What's Changed

This it the official **Python 3.13** support! Now, **FastStream** works (and tested) at **Python 3.8 - 3.13** versions!

Warning: **Python3.8** is EOF since **3.13** release and we plan to drop it support in **FastStream 0.6.0** version.

Also, current release has little bugfixes related to **CLI** and **AsyncAPI** schema.

* fix: asgi docs by [@Sehat1137](https://github.com/Sehat1137){.external-link target="_blank"} in [#1828](https://github.com/airtai/faststream/pull/1828){.external-link target="_blank"}
* docs: add link to RU TG community by [@Lancetnik](https://github.com/Lancetnik){.external-link target="_blank"} in [#1831](https://github.com/airtai/faststream/pull/1831){.external-link target="_blank"}
* docs: add dynaconf NATS HowTo example by [@sheldygg](https://github.com/sheldygg){.external-link target="_blank"} in [#1832](https://github.com/airtai/faststream/pull/1832){.external-link target="_blank"}
* Fix AsyncAPI 2.6.0 operation label by [@KrySeyt](https://github.com/KrySeyt){.external-link target="_blank"} in [#1835](https://github.com/airtai/faststream/pull/1835){.external-link target="_blank"}
* fix: correct CLI factory behavior by [@Lancetnik](https://github.com/Lancetnik){.external-link target="_blank"} in [#1838](https://github.com/airtai/faststream/pull/1838){.external-link target="_blank"}
* Autocommit precommit changes by [@kumaranvpl](https://github.com/kumaranvpl){.external-link target="_blank"} in [#1840](https://github.com/airtai/faststream/pull/1840){.external-link target="_blank"}
* Add devcontainers supporting all the brokers by [@kumaranvpl](https://github.com/kumaranvpl){.external-link target="_blank"} in [#1839](https://github.com/airtai/faststream/pull/1839){.external-link target="_blank"}
* Replace async Event with bool by [@Olegt0rr](https://github.com/Olegt0rr){.external-link target="_blank"} in [#1846](https://github.com/airtai/faststream/pull/1846){.external-link target="_blank"}
* Add support for Python 3.13 by [@davorrunje](https://github.com/davorrunje){.external-link target="_blank"} in [#1845](https://github.com/airtai/faststream/pull/1845){.external-link target="_blank"}

**Full Changelog**: [#0.5.25...0.5.26](https://github.com/airtai/faststream/compare/0.5.25...0.5.26){.external-link target="_blank"}

## 0.5.25

Expand Down
2 changes: 1 addition & 1 deletion faststream/_internal/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def with_info_plain_validator_function( # type: ignore[misc]
return {}


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


Expand Down
5 changes: 4 additions & 1 deletion faststream/_internal/fastapi/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
from fastapi.dependencies.models import Dependant
from fastapi.requests import Request

major, minor, patch, *_ = map(int, FASTAPI_VERSION.split("."))
major, minor, patch, *_ = FASTAPI_VERSION.split(".")
major = int(major)
minor = int(minor)
patch = int(patch)
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)
Expand Down
2 changes: 1 addition & 1 deletion faststream/_internal/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def timeout_scope(
raise_timeout: bool = False,
) -> AbstractContextManager[anyio.CancelScope]:
scope: Callable[[Optional[float]], AbstractContextManager[anyio.CancelScope]]
scope = anyio.fail_after if raise_timeout else anyio.move_on_after # type: ignore[assignment]
scope = anyio.fail_after if raise_timeout else anyio.move_on_after

return scope(timeout)

Expand Down
10 changes: 7 additions & 3 deletions faststream/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ def __init__(
on_shutdown=on_shutdown,
after_shutdown=after_shutdown,
)
self._should_exit = anyio.Event()
self._should_exit = False

async def run(
self,
log_level: int = logging.INFO,
run_extra_options: Optional[dict[str, "SettingField"]] = None,
sleep_time: float = 0.1,
) -> None:
"""Run FastStream Application."""
assert self.broker, "You should setup a broker" # nosec B101
Expand All @@ -73,7 +74,10 @@ async def run(
try:
async with anyio.create_task_group() as tg:
tg.start_soon(self._startup, log_level, run_extra_options)
await self._should_exit.wait()

while not self._should_exit: # noqa: ASYNC110 (requested by creator)
await anyio.sleep(sleep_time)

await self._shutdown(log_level)
tg.cancel_scope.cancel()
except ExceptionGroup as e:
Expand All @@ -82,7 +86,7 @@ async def run(

def exit(self) -> None:
"""Stop application manually."""
self._should_exit.set()
self._should_exit = True

def as_asgi(
self,
Expand Down
22 changes: 13 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ rabbit = ["aio-pika>=9,<10"]

kafka = ["aiokafka>=0.9,<0.12"]

confluent = ["confluent-kafka>=2,<3"]
confluent = [
"confluent-kafka>=2,<3; python_version < '3.13'",
"confluent-kafka>=2.6,<3; python_version >= '3.13'",
]

nats = ["nats-py>=2.7.0,<=3.0.0"]

Expand All @@ -83,15 +86,15 @@ cli = [
optionals = ["faststream[rabbit,kafka,confluent,nats,redis,otel,cli]"]

devdocs = [
"mkdocs-material==9.5.39",
"mkdocs-material==9.5.40",
"mkdocs-static-i18n==1.2.3",
"mdx-include==1.4.2",
"mkdocstrings[python]==0.26.1",
"mkdocstrings[python]==0.26.2",
"mkdocs-literate-nav==0.6.1",
"mkdocs-git-revision-date-localized-plugin==1.2.9",
"mike==2.1.3", # versioning
"mkdocs-minify-plugin==0.8.0",
"mkdocs-macros-plugin==1.2.0", # includes with variables
"mkdocs-macros-plugin==1.3.5", # includes with variables
"mkdocs-glightbox==0.4.0", # img zoom
"pillow", # required for mkdocs-glightbo
"cairosvg", # required for mkdocs-glightbo
Expand All @@ -100,7 +103,7 @@ devdocs = [

types = [
"faststream[optionals]",
"mypy==1.11.2",
"mypy==1.12.0",
# mypy extensions
"types-Deprecated",
"types-PyYAML",
Expand All @@ -116,20 +119,21 @@ lint = [
"faststream[types]",
"ruff==0.6.9",
"bandit==1.7.10",
"semgrep==1.90.0",
"semgrep==1.91.0",
"codespell==2.3.0",
]

test-core = [
"coverage[toml]==7.6.1",
"coverage[toml]==7.6.1; python_version == '3.8'",
"coverage[toml]==7.6.3; python_version >= '3.9'",
"pytest==8.3.3",
"pytest-asyncio==0.24.0",
"dirty-equals==0.8.0",
]

testing = [
"faststream[test-core]",
"fastapi==0.115.0",
"fastapi==0.115.2",
"pydantic-settings>=2.0.0,<3.0.0",
"httpx==0.27.2",
"PyYAML==6.0.2",
Expand All @@ -138,7 +142,7 @@ testing = [

dev = [
"faststream[optionals,lint,testing,devdocs]",
"pre-commit==4.0.0",
"pre-commit==4.0.1",
"detect-secrets==1.5.0",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from dirty_equals import IsPartialDict

from docs.docs_src.getting_started.asyncapi.asyncapi_customization.custom_handler import (
docs_obj,
)
Expand All @@ -6,23 +8,31 @@
def test_handler_customization() -> None:
schema = docs_obj.to_jsonable()

assert schema["channels"] == {
"input_data:Consume": {
"description": "Consumer function\n\n Args:\n msg: input msg\n ",
"servers": ["development"],
"bindings": {"kafka": {"topic": "input_data", "bindingVersion": "0.4.0"}},
"subscribe": {
"message": {"$ref": "#/components/messages/input_data:Consume:Message"},
},
(subscriber_key, subscriber_value), (publisher_key, publisher_value) = schema[
"channels"
].items()

assert subscriber_key == "input_data:Consume", subscriber_key
assert subscriber_value == IsPartialDict({
"servers": ["development"],
"bindings": {"kafka": {"topic": "input_data", "bindingVersion": "0.4.0"}},
"subscribe": {
"message": {"$ref": "#/components/messages/input_data:Consume:Message"},
},
"output_data:Produce": {
"description": "My publisher description",
"servers": ["development"],
"bindings": {"kafka": {"topic": "output_data", "bindingVersion": "0.4.0"}},
"publish": {
"message": {
"$ref": "#/components/messages/output_data:Produce:Message"
},
},
}), subscriber_value
desc = subscriber_value["description"]
assert ( # noqa: PT018
"Consumer function\n\n" in desc
and "Args:\n" in desc
and " msg: input msg" in desc
), desc

assert publisher_key == "output_data:Produce", publisher_key
assert publisher_value == {
"description": "My publisher description",
"servers": ["development"],
"bindings": {"kafka": {"topic": "output_data", "bindingVersion": "0.4.0"}},
"publish": {
"message": {"$ref": "#/components/messages/output_data:Produce:Message"}
},
}

0 comments on commit 77905ff

Please sign in to comment.