Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Depends error with incoming message #1271

Closed
maxim-f1 opened this issue Feb 27, 2024 · 1 comment
Closed

Bug: Depends error with incoming message #1271

maxim-f1 opened this issue Feb 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@maxim-f1
Copy link

When using Depends and a schema to receive a message via Pydantic Model, an error occurs if the scheme is not explicitly specified as a parameter in the subscriber function.

I would like Faststream to realize that this is an incoming schema the first time the model is annotated, even if it happens inside the Depends function.

async def depends(body: DTO, session: get_session):
	return body


depends_annotated = Annotated[
	DTO, faststream.Depends(depends)
]

router = RabbitRouter()

@router.subscriber(
	queue=DTO.queue,
)
async def handler(result: depends_annotated):
	return result


@router.subscriber(
	queue=DTO.queue,
)
async def handler(body: DTO, result: depends_annotated):
	return result
@Lancetnik
Copy link
Member

We should mv this Issue to FastDepends

Incorrect behavior:

from fast_depends import Depends, inject

def dep(a: str):
    return a
    
@inject
def func(result: str  = Depends(dep)):
    print(result)
 
func("test")

@Lancetnik Lancetnik closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 27, 2024
* fix (#1271): correct AsyncAPI schema in descriminator case

* lint: fix types

* tests: RMQ-compatible tests

* fix: mypy ignores

* chore: bump version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants