镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Preserve callable factory return types in hashlib.file_digest - #16508

Merged
srittau merged 2 commits into
python:mainfrom
xiehuanyi:fix-file-digest-factory-return
Oct 12, 2026
Merged

srittau merged 2 commits into
python:mainfrom
xiehuanyi:fix-file-digest-factory-return

Conversation

@xiehuanyi

Copy link
Copy Markdown
Contributor

Callable factories for hashlib.file_digest() retain their own type at runtime, but the stub currently returns HASH for factories producing hmac.HMAC or blake2b.

Separate the string and callable overloads to preserve the factory return type, matching the documented HMAC example.

Agent used: Codex (GPT-6.1-sol) for investigation, implementation, and verification.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 18:06

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 reached their quota limit.

@github-actions

This comment has been minimized.

Comment thread stdlib/hashlib.pyi Outdated
algorithms_guaranteed: AbstractSet[str]
algorithms_available: AbstractSet[str]

_T = TypeVar("_T", bound=_HashObject)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use a name other than _T, which is often used to indicate an unbound type var. Maybe _HashT? Also please move it to the top before def new.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@srittau
srittau merged commit 845f4dd into python:main Oct 12, 2026
88 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.

3 participants