Repository navigation
Deprecate the string parameter of hash constructors - #16931
Merged
Merged
Conversation
Assisted-by: Claude Code (Claude Opus 5.5)
This comment has been minimized.
This comment has been minimized.
Assisted-by: Claude Code (Claude Opus 5.5)
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: apprise (https://github.com/caronc/apprise)
- apprise/persistent_store.py:172: error: Attribute function "hash_engine" with type "def openssl_sha256(data: Buffer = ..., *, usedforsecurity: bool = ..., string: Buffer | None = ...) -> HASH" does not accept self argument [misc]
+ apprise/persistent_store.py:172: error: Attribute function "hash_engine" with type "def openssl_sha256(data: Buffer = ..., *, usedforsecurity: bool = ...) -> HASH" does not accept self argument [misc]
- apprise/persistent_store.py:172: error: Function gets multiple values for keyword argument "usedforsecurity" [misc]
- apprise/persistent_store.py:173: error: Argument 1 has incompatible type "bytes"; expected "bool" [arg-type]
+ apprise/persistent_store.py:172: error: No overload variant matches argument types "bytes", "bool" [call-overload]
+ apprise/persistent_store.py:172: note: Possible overload variants:
+ apprise/persistent_store.py:172: note: def openssl_sha256(data, *, usedforsecurity: bool = ...) -> HASH
+ apprise/persistent_store.py:172: note: def openssl_sha256(usedforsecurity, *, string: Buffer | None) -> HASH
|
srittau
approved these changes
Dec 1, 2026
srittau
left a comment
Collaborator
There was a problem hiding this comment.
Normally, our deprecations are Python-version exact (>= 3.15 in this instance), but considering that this only ever worked properly in 3.13 and 3.14, according to the docs, an unconditional deprecation seems fine to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Python 3.15, passing the initial data as
string=tohashlib.new(), the OpenSSL-backed constructors such ashashlib.md5(), andblake2b/blake2semits aDeprecationWarning, and the keyword is slated for removal in 3.19 (docs). This movesstringinto separate@deprecatedoverloads on the 3.13+ branch, wheredatais the alternative, so passing bothdataandstringis now rejected as it is at runtime.Prepared with Claude Code (Claude Opus 5.5).