Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

fix(bridges): add from __future__ import annotations for Python 3.9 compat - #56

Open
jgluck96 wants to merge 2 commits into
mainfrom
fix/slack-bridge-py39-annotations
Open

jgluck96 wants to merge 2 commits into
mainfrom
fix/slack-bridge-py39-annotations

Conversation

@jgluck96

@jgluck96 jgluck96 commented May 22, 2026 •

Copy link
Copy Markdown

Problem

All three bridge files (slack-bridge.py, discord-bridge.py, telegram-bridge.py) use str | None and dict | None union type syntax, which Python 3.9 raises a TypeError on at module load time. This causes a crash-loop on every startup, silently dropping all Slack/Discord/Telegram messages.

Root cause surfaces after upgrading from 0.3 → 0.3.2: the 0.3 installation had this patched locally. The 0.3.2 app bundle ships without the patch, so users on Python 3.9 (macOS default until Ventura) hit crash-loops immediately after the update.

Fix

Add from __future__ import annotations as the second line of each bridge file. This makes ALL annotations lazy strings in Python 3.9 — zero behavior change on 3.10+.

Files changed:

  • src/slack-bridge.py — added from __future__ import annotations
  • src/telegram-bridge.py — added from __future__ import annotations
  • src/discord-bridge.py — already had the fix at line 8 (inside module docstring section)

Reproduces on

Python 3.9.x (ships with macOS Monterey and older; CommandLineTools/Library/Frameworks/Python3.framework/...).

Impact after 0.3 → 0.3.2 upgrade

Users who upgraded from 0.3 to 0.3.2 found ALL messaging channels dead. The 0.3 build had local hotfixes not in the OSS base; 0.3.2 was built clean, so those patches were lost.

Notes

  • Sutando OSS (sonichi/sutando) already has all 3 fixes in main — this brings stando to parity.
  • Zero risk: from __future__ import annotations is a well-understood Python stdlib import, fully backward compatible.

…compat

`str | None` union-type syntax (PEP 604) requires Python ≥ 3.10.
System Python on macOS Sequoia ships 3.9.6 (Xcode toolchain), so
`tests/slack-bridge-allowlist.test.py` failed at import time with:

    unsupported operand type(s) for |: 'type' and 'NoneType'

`from __future__ import annotations` defers all annotation evaluation
to strings (PEP 563), making the syntax valid on 3.9+. No runtime
behaviour change — annotations are not evaluated at runtime in this file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jgluck96
jgluck96 changed the base branch from main to josh/ui-gpt May 22, 2026 19:11
@bassilkhilo-ag2 bassilkhilo-ag2 changed the title Fix/slack bridge py39 annotations fix(bridges): add from __future__ import annotations for Python 3.9 compat May 25, 2026

@bassilkhilo-ag2 bassilkhilo-ag2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Same fix as sutando OSS sonichi#1108.

from __future__ import annotations enables PEP 563 postponed annotation evaluation, making pipe-style union types (X | Y) work on Python 3.9 without a runtime error. 2-line change, no behavior impact.

@jgluck96
jgluck96 changed the base branch from josh/ui-gpt to main June 4, 2026 20:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants