Skip to content

mypy fails on fresh installs: joserfc 1.8.0 types OKPKey/ECKey.import_key() as returning Any #1845

Closed as not planned

Description

@bokelley

joserfc 1.8.0 was published to PyPI at 2026-11-03 10:45 UTC. It changes ECKey.import_key() / OKPKey.import_key() to return Self, and mypy now types the result as Any. adcp pins joserfc>=1.7.5,<2, so a fresh resolve gets 1.8.0, and strict mypy (no-any-return) fails in four places:

src/adcp/signing/publisher_pins.py:38: error: Returning Any from function declared to return "str | None"  [no-any-return]
src/adcp/signing/crypto.py:129: error: Returning Any from function declared to return "OKPKey | ECKey"  [no-any-return]
src/adcp/governance.py:1687: error: Returning Any from function declared to return "OKPKey | ECKey"  [no-any-return]
src/adcp/governance.py:1689: error: Returning Any from function declared to return "OKPKey | ECKey"  [no-any-return]

This failed the Test Python 3.12 type-check job on #1840, a docs-only PR (run 41623407861, and again on rerun). I reproduced it locally with joserfc==1.8.0; with 1.7.7 mypy is clean. Runtime behaviour is unaffected.

Fix: bind each import_key() result to an annotated local before returning it. cast() would be flagged as redundant under 1.7.x, because strict = true enables warn_redundant_casts.

🤖 Generated with Claude Code

Activity

  1. added
    bugSomething isn't working
    no-triageSkip the Claude triage bot — human or designated agent will handle this issue
    on Nov 3, 2026
  2. bokelley commented on Nov 3, 2026

    @bokelley
    ContributorAuthor

    Already fixed on next by a541585, which binds each import_key() result to an annotated local in crypto.py, publisher_pins.py and governance.py, despite its unrelated title. #1840 and #1843 were cut before it; rebasing them picks it up.

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

    bugSomething isn't workingno-triageSkip the Claude triage bot — human or designated agent will handle this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions