Skip to content

[Bug]: google_api.py crashes on Python 3.9 — missing from __future__ import annotations #16257

Open

Description

@jerome-benoit

Bug Description

google_api.py is missing from __future__ import annotations, causing a TypeError on Python 3.9 (macOS system python) due to PEP 604 union syntax (str | None).

PR #15405 added the future import to setup.py but missed google_api.py, which uses str | None on lines 82 and 95.

Steps to Reproduce

python3 --version  # Python 3.9.6 (macOS system)
python3 ~/.hermes/skills/productivity/google-workspace/scripts/google_api.py gmail search "is:unread" --max 1

Expected Behavior

JSON output with search results.

Actual Behavior

Traceback (most recent call last):
  File ".../google_api.py", line 82, in <module>
    def _gws_binary() -> str | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Affected Component

Skills (skill loading, skill hub, skill guard)

Debug Report

Hermes Agent v0.11.0 (2026.4.23)
Python: 3.12.13 (Nix), 3.9.6 (macOS system /usr/bin/python3)
macOS 26.4.1

Operating System

macOS 26.4.1 (Apple Silicon)

Python Version

3.9.6 (/usr/bin/python3 — the one that has pip and the Google deps installed via setup.py --install-deps)

Hermes Version

0.11.0

Root Cause Analysis

google_api.py lines 82 and 95 use PEP 604 union syntax:

def _gws_binary() -> str | None:                                          # L82
def _run_gws(parts: list[str], *, params: dict | None = None, ...):       # L95

This requires Python 3.10+. On 3.9, from __future__ import annotations makes it parse correctly (annotations become strings, not evaluated). PR #15405 commit 2ffcc57 added this to setup.py but not google_api.py.

Proposed Fix

One-liner — add after the shebang, before the module docstring:

from __future__ import annotations

Same pattern already applied in setup.py and _hermes_home.py.

  • I'd like to fix this myself and submit a PR

Activity

  1. added
    type/bugSomething isn't working
    P3Low — cosmetic, nice to have
    tool/skillsSkills system (list, view, manage)
    on Apr 27, 2026
  2. alt-glitch commented on Apr 27, 2026

    @alt-glitch

    Related to PR #15158 (same root cause: missing from __future__ import annotations for PEP 604 syntax). #15158 fixed setup.py but missed google_api.py. Also related to PR #13765 (bulk future annotations fix across 112 files).

  3. briandevans commented on Apr 27, 2026

    @briandevans

    Heads up — this is already fixed in open PR #15158, which adds from __future__ import annotations to both hermes_constants.py and skills/productivity/google-workspace/scripts/google_api.py.

    The _gws_binary() -> str | None annotation on line 82 (and any others) will work on Python 3.9 once that PR merges. No separate fix needed.

  4. vominh1919 commented on Apr 27, 2026

    @vominh1919

    Submitted PR #16272 with a fix. Added from __future__ import annotations to all 3 affected skill scripts:

    • google_api.py (primary)
    • pack.py (powerpoint)
    • add_slide.py (powerpoint)

    setup.py already had the import. The fix is zero-functional-change — PEP 604 annotations become lazy strings on Python 3.9.

  5. GottZ commented on Jul 29, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    One PR directly addresses issue #16257. #16272 adds postponed annotation evaluation to google_api.py, eliminating the reported Python 3.9 import-time TypeError, and applies the same fix to two bundled PowerPoint scripts with equivalent PEP 604 usage.

    Related pull requests

    Suggested consolidation

    Merge #16272 after addressing the keep_open review through an explicit scope correction and executable Python 3.9 regression coverage; its diff directly fixes the reported cause and the two same-class bundled occurrences. There are no competing triaged PRs to close as duplicates.

    Complex graph

    flowchart LR
        classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
        classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
        classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
        classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
        classDef best stroke-width:3px,stroke:#b45309
        classDef target stroke-width:3px,stroke:#4338ca
        I16257(["issue #16257 (open)"])
        P16272["PR #16272 (open)"]
        P16272 -->|best fix| I16257
        class I16257 open
        class I16257 target
        class P16272 open
        class P16272 best
        click I16257 "https://github.com/NousResearch/hermes-agent/issues/16257"
        click P16272 "https://github.com/NousResearch/hermes-agent/pull/16272"
    
    Loading

    Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

    Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 1 kB of PR diffs, 3 kB of issue/PR text, 2 kB of discussion (4 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

  6. kcs2092 commented on Sep 27, 2026

    @kcs2092

    Confirming reproduction on this side too (macOS, system Python 3.9.6 reachable on PATH for terminal-tool-spawned subprocesses). PR #16272's file list doesn't cover skills/software-development/github/scripts/git-credential-token.py, which has the identical bug — filed separately as #125202 since it's a different skill, but flagging here in case #16272 wants to sweep it in too.

  7. MuhammadUsamaMX commented on Oct 18, 2026

    @MuhammadUsamaMX

    Fixed in #19. One thing worth flagging for anyone else picking this up: the one-line fix in the issue is not sufficient on current main.

    google_api.py has a second, independent Python 3.9 blocker — line 36:

    from datetime import datetime, timedelta, timezone, UTC

    datetime.UTC is a 3.11+ alias, so once the future import is in place the script still fails on 3.9, with a different error:

    google_api.py: ImportError: cannot import name 'UTC' from 'datetime'
    

    gws_bridge.py in the same directory has the same import. Replacing with timezone.utc (which UTC aliases) resolves it.

    This is invisible to ast.parse, since PEP 604 is a runtime failure and UTC is an import — so a parse-only check reports the script as fixed while it still crashes.

    Reproduced on real CPython 3.9.25, and confirmed the issue's diagnosis is exactly right for the original traceback: without the future import, L82 raises the reported TypeError.

    Scope in #19: google_api.py, gws_bridge.py (UTC), git-credential-token.py (@kcs2092's find), and fetch_transcript.py (same annotation class, found by sweeping). All four go from failing to importing cleanly under 3.9. An AST sweep confirms no other bundled skill script has the annotation form of this bug.

  8. alt-glitch commented on Oct 18, 2026

    @alt-glitch

    #16272 aims to fix this: it adds the future annotations import to the Google Workspace API script so the union type hints no longer crash on Python 3.9.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havetool/fileFile tools (read, write, patch, search)tool/skillsSkills system (list, view, manage)type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions