Skip to content

Conversation

@Vizonex
Copy link
Contributor

@Vizonex Vizonex commented Oct 16, 2025

What do these changes do?

These changes are made to better reflect the documentation on Exception Handlers as mentioned in #565
Might need a little help & Guidance with this one :/

Are there changes in behavior for the user?

Typehinting changes for Exception Handler Callbacks mainly meant to assist and add context from the provided documentation

Related issue number

Fixes #565

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@Vizonex
Copy link
Contributor Author

Vizonex commented Oct 19, 2025

@Dreamsorcerer I'll come back sometime in a couple of hours later today to mark a few mypy things off as ignorable because the default handler expects a something other than a context instead of something else. Here's the error from the workflow if you need a bit of context something to mark these as truthy in the python code might be nessesary...

aiojobs/_job.py:151:46: error: Argument 1 to "call_exception_handler" of
"Scheduler" has incompatible type "dict[str, object]"; expected
"ExceptionHandlerDict"  [arg-type]
                scheduler.call_exception_handler(context)
                                                 ^~~~~~~
aiojobs/_job.py:182:48: error: Argument 1 to "call_exception_handler" of
"Scheduler" has incompatible type "dict[str, object]"; expected
"ExceptionHandlerDict"  [arg-type]
            self._scheduler.call_exception_handler(context)
                                                   ^~~~~~~
aiojobs/_scheduler.py:31:10: error: Missing type parameters for generic type
"Job"  [type-arg]
        job: Job
             ^
aiojobs/_scheduler.py:239:63: error: Argument 1 to "call_exception_handler" of
"AbstractEventLoop" has incompatible type "ExceptionHandlerDict"; expected
"dict[str, Any]"  [arg-type]
                asyncio.get_running_loop().call_exception_handler(context)
                                                                  ^~~~~~~
tests/test_scheduler.py:241:38: error: Argument 1 to "call_exception_handler"
of "Scheduler" has incompatible type "dict[str, str]"; expected
"ExceptionHandlerDict"  [arg-type]
        scheduler.call_exception_handler(d)
                                         ^
Found 5 errors in 3 files (checked 9 source files)

@Dreamsorcerer
Copy link
Member

aiojobs/_scheduler.py:239:63 is essentially a bug/limitation in mypy. The others are typing issues in our code that should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider using TypedDict for 2nd ExceptionHandler parameter

2 participants