Skip to content

Add optional keyring_type parameter to get_keyring() and type SecretService.get_preferred_collection - #779

Open
faresrafat3 wants to merge 1 commit into
jaraco:mainfrom
faresrafat3:fix-645-get-keyring-typing
Open

faresrafat3 wants to merge 1 commit into
jaraco:mainfrom
faresrafat3:fix-645-get-keyring-typing

Conversation

@faresrafat3

@faresrafat3 faresrafat3 commented Oct 23, 2026 •

Copy link
Copy Markdown

Annotate SecretService.Keyring.get_preferred_collection(): it returns a secretstorage.collection.Collection, but was untyped, so callers in typed contexts saw Call to untyped function "get_preferred_collection" in typed context [no-untyped-call]. One annotation, one TYPE_CHECKING-guarded import; no runtime behaviour changes and no public API is added.

This addresses the [no-untyped-call] half of #645. The other error reported there — Incompatible types in assignment (expression has type "KeyringBackend", variable has type "Keyring") when get_keyring()'s result is assigned to a concrete backend — is a return-narrowing question that would require changing get_keyring()'s signature, and that is deliberately out of scope here: it needs its own issue and maintainer agreement on the API before anyone sends the diff. So Refs #645 and not a full fix.

The module has no from __future__ import annotations, so the annotation is quoted and the import sits under if typing.TYPE_CHECKING:; secretstorage is listed in mypy.ini's ignore_missing_imports stanza, so the type resolves for checkers without being a runtime dependency. No newsfragment: typing-only changes in this repo have merged without one (#691, #666), and there is no user-facing behaviour change to announce.

Written with AI assistance; the change was reviewed and verified before submission.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 18:36

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@faresrafat3
faresrafat3 force-pushed the fix-645-get-keyring-typing branch from dc5157b to c2db8f5 Compare October 24, 2026 07:55
The method returns a secretstorage.collection.Collection but was untyped,
so callers in typed contexts got, as reported in jaraco#645:

    Call to untyped function "get_preferred_collection" in typed context
    [no-untyped-call]

This module has no ``from __future__ import annotations``, so the
annotation is quoted and the import is guarded by ``TYPE_CHECKING``.

This addresses only the ``no-untyped-call`` half of jaraco#645. The other error
reported there, ``Incompatible types in assignment`` when assigning
``get_keyring()``'s result to a concrete backend variable, is a question
about ``get_keyring()``'s return type that needs its own issue and
maintainer agreement on the API, and is deliberately out of scope here.

Ref jaraco#645.

Co-Authored-By: Claude <noreply@anthropic.com>
@faresrafat3
faresrafat3 force-pushed the fix-645-get-keyring-typing branch from c2db8f5 to 84268c5 Compare October 24, 2026 08:36
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.

2 participants