Unable to resolve the dependency

@router.callback_query(F.data == "callback")
@inject
async def schedule_handler(
    query: CallbackQuery,
    bot: Bot, 
    settings_service: Annotated[SettingsService, Depends()],
    scheduler: AsyncIOScheduler,
    event_chat: Chat,
    mailing_manager: Annotated[AutoMailingManager, Depends()],
) -> None:
# (удалил не нужную часть кода)
        if schedule_time:
            try:
                job = scheduler.get_jobs()
                if job:
                    scheduler.remove_job(str(user_id))
                    
                scheduler.add_job(
                    func=AutoMailingManager.mailing,
                    trigger="cron",
                    hour=schedule_time.hour,
                    minute=schedule_time.minute,
                    kwargs={"user_id": user_id}, 
                    id=str(user_id)
                )
                await settings_service.update_settings(user_id=user_id, is_turned_on=True)
            except SMTPAuthenticationError:
                await bot.send_message(
                    chat_id=event_chat.id,
                    text='Не удалось аутенцифитироваться в вашем аккаунте'
                )
            except Exception as ex:
                print(ex)

error

Traceback (most recent call last):
  File "C:\Python_all_projects\Ordered TG Bots\Shrink2\.venv\Lib\site-packages\apscheduler_di\_binding.py", line 114, in resolve_dependencies
    instance = services.get(param_spec.annotation, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python_all_projects\Ordered TG Bots\Shrink2\.venv\Lib\site-packages\rodi\__init__.py", line 744, in get
    raise CannotResolveTypeException(desired_type)
rodi.CannotResolveTypeException: Unable to resolve the type '<class 'inspect._empty'>'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python_all_projects\Ordered TG Bots\Shrink2\.venv\Lib\site-packages\apscheduler\executors\base_py3.py", line 30, in run_coroutine_job
    retval = await job.func(*job.args, **job.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python_all_projects\Ordered TG Bots\Shrink2\.venv\Lib\site-packages\apscheduler_di\_binding.py", line 102, in wrapper     
    return await func(*resolve_dependencies(services, func, **kwargs))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python_all_projects\Ordered TG Bots\Shrink2\.venv\Lib\site-packages\apscheduler_di\_binding.py", line 118, in resolve_dependencies
    raise UnableToResolveDependencyError(
apscheduler_di._binding.UnableToResolveDependencyError: Unable to resolve the dependency: Instance of self argument found neither in apscheduler-di context nor in kwargs argument

class AutoMailingManager:

class AutoMailingManager():
    def __init__(
        self,
        extra_mailing: ExtraMailing,
        email_service: EmailService,
        settings_service: SettingsService,
        user_service: UserService,
        email_dal: UserEmailDAL,
        audio_dal: UserAudioDAL,
    ) -> None:
        self._client = SMTP(hostname='smtp.gmail.com', port=587)
        self._email = MIMEMultipart()
        self._extra_mailing = extra_mailing
        self._email_service = email_service
        self._settings_service = settings_service
        self._email_dal = email_dal
        self._audio_dal = audio_dal
        self._user_service = user_service

    async def mailing(self, user_id: int) -> None:
              pass

У меня есть apscheduler, к которому подключен Redis. Я пробрасываю его в хендлер и при вызове таски у меня возникает проблема с зависимостями

self argument not found

Но если я в параметре func изменю так, чтобы метод вызывался от экземпляра класса, которую я пробросил в хендлер через библиотеку dishka, то будет ошибка связанная с редисом: "cant pickle local object". Как я могу решить эту проблему?


Ответы (0 шт):