Skip to content

Fix Python 3.16 retry compatibility with python-backoff - #1205

Open
BookCatKid wants to merge 2 commits into
bachya:devfrom
BookCatKid:fix/python-backoff-py316
Open

BookCatKid wants to merge 2 commits into
bachya:devfrom
BookCatKid:fix/python-backoff-py316

Conversation

@BookCatKid

@BookCatKid BookCatKid commented Dec 5, 2026 •

Copy link
Copy Markdown

Describe what the PR does:

Prevent Python 3.16 retry failures by replacing the original backoff dependency (which calls the removed asyncio.iscoroutinefunction() API) with the maintained python-backoff>=2.3.1 fork.

The dependency swap alone is not safe for SimpliSafe: on python-backoff 2.4.0, nine existing tests fail because the retry callbacks call sys.exc_info() after the fork has exited the exception handler. The fork supplies the caught exception in the callback details["exception"]; use that documented callback detail in both _async_handle_on_backoff and _handle_on_giveup instead. This preserves the 401 token-refresh behavior, the give-up exception chaining, and compatibility with both 2.3.1 and 2.4.0. Existing API method interfaces stay the same.

The Poetry lockfile was regenerated using Poetry 2.4.1, matching its existing generator; it only changes the affected dependency entries.

Testing:

  • Baseline backoff 2.2.1: 94 tests passed.
  • python-backoff 2.4.0 before callback fix: 9 tests failed, demonstrating the issue.
  • After callback fix: 94 tests passed with 100% coverage on each of the original 2.2.1, fork 2.3.1, and fork 2.4.0.
  • Added a regression test that exercises the callback handlers when no exception is active on the stack; final run with 2.4.0: 95 passed, 100% coverage.
  • python-backoff 3.1.0: 95 tests passed on Python 3.14.
  • poetry check --lock, Black formatting check for the new test, and git diff --check passed.
  • The existing unrelated Black discrepancy in the annotation of _refresh_token_callbacks was not modified.

No real SimpliSafe cloud credentials or equipment were needed for these mocked tests.

Does this fix a specific issue?

No existing upstream issue identified; fixes the Python 3.16 incompatibility reported by Home Assistant Hassfest.

Checklist:

  • Confirm that one or more new tests are written for the new functionality.
  • Run tests and ensure everything passes (with 100% test coverage).
  • Update README.md with any new documentation. (Not applicable: internal compatibility change only; no documented API change.)

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.

1 participant