Skip to content

Commit

Permalink
Check if annotation is AsyncSession
Browse files Browse the repository at this point in the history
instead of default value
  • Loading branch information
armanddidierjean committed Dec 5, 2024
1 parent 0e7f032 commit af60d98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/types/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async def run_task(
require_db_for_kwargs: list[str] = []
sign = signature(job_function)
for param in sign.parameters.values():
if isinstance(param.default, AsyncSession):
# See https://docs.python.org/3/library/inspect.html#inspect.Parameter.annotation
if param.annotation is AsyncSession:
# We iterate over the parameters of the job_function
# If we find a AsyncSession object, we want to inject the dependency
require_db_for_kwargs.append(param.name)
Expand Down

0 comments on commit af60d98

Please sign in to comment.