Skip to content

Fix SyntaxError on Python 3.13 (Home Assistant before 2026.3) - #179

Merged
iantrich merged 1 commit into
custom-components:masterfrom
ogajduse:fix/py313-syntax
Nov 16, 2026
Merged

iantrich merged 1 commit into
custom-components:masterfrom
ogajduse:fix/py313-syntax

Conversation

@ogajduse

Copy link
Copy Markdown
Collaborator

Fixes #178.

1.4.0 doesn't import on Python 3.13, so it breaks on Home Assistant 2025.8–2026.2, which hacs.json still allows. This PR:

  • reader.py: restores except (ValueError, OverflowError):. The unparenthesized form came in with Fetch feeds through an optional HTTP or SOCKS proxy #175 and only parses on Python 3.14 (PEP 758).
  • ruff: sets target-version to py313 for the integration, so ruff neither writes nor accepts 3.14-only syntax. With py313, ruff reports the line above as a syntax error. tests/ stays on py314 through per-file-target-version, because the test dependencies need 3.14 and tests/feedsource.py relies on lazy annotations.
  • CI: adds a small "Python 3.13 syntax" job that runs compileall on custom_components. The full test suite can't run on 3.13, since pytest-homeassistant-custom-component pins HA 2026.10.

Raising the hacs.json minimum to 2026.3.0 would also avoid the crash, but it would drop users on older HA. I left that decision open.

Verification

  • Python 3.13.6 with Home Assistant 2026.2.3: all nine modules of the integration import. On master, reader.py fails with SyntaxError: multiple exception types must be parenthesized.
  • pytest tests on Python 3.14: 239 passed, 2 deselected.
  • pre-commit run on the changed files passes (ruff 0.12.12, black, mypy, pretty-format-toml).

🤖 Generated with Claude Code

`except ValueError, OverflowError:` is only valid from Python 3.14
(PEP 758), so 1.4.0 fails to import on Home Assistant 2025.8-2026.2,
which run on Python 3.13 and which hacs.json still allows. Restore the
parentheses.

Keep ruff on py313 for the integration so it neither writes nor accepts
3.14-only syntax; the tests stay on py314 because their dependencies
need it and they rely on lazy annotations. Add a CI job that compiles
the integration with Python 3.13.

Fixes custom-components#178

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ogajduse
ogajduse requested a review from iantrich November 16, 2026 09:52
@iantrich
iantrich merged commit bf8453c into custom-components:master Nov 16, 2026
5 checks passed
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.4.0 fails to load on Home Assistant 2025.8–2026.2 (Python 3.13): SyntaxError in reader.py

2 participants