Title: hashlib `digest()` fails typecheck for variable-length digests `SHAKE-128` and `SHAKE-256` · Issue #16480 · python/typeshed · GitHub
Open Graph Title: hashlib `digest()` fails typecheck for variable-length digests `SHAKE-128` and `SHAKE-256` · Issue #16480 · python/typeshed
X Title: hashlib `digest()` fails typecheck for variable-length digests `SHAKE-128` and `SHAKE-256` · Issue #16480 · python/typeshed
Description: the hashlib package supports variable-length digests SHAKE-128 and SHAKE-256. For those objects, digest() and hexdigest() both need to take a length parameter, without which they fail missing required argument 'length' (pos 1). (other di...
Open Graph Description: the hashlib package supports variable-length digests SHAKE-128 and SHAKE-256. For those objects, digest() and hexdigest() both need to take a length parameter, without which they fail missing requi...
X Description: the hashlib package supports variable-length digests SHAKE-128 and SHAKE-256. For those objects, digest() and hexdigest() both need to take a length parameter, without which they fail missing requi...
Opengraph URL: https://github.com/python/typeshed/issues/16480
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"hashlib `digest()` fails typecheck for variable-length digests `SHAKE-128` and `SHAKE-256`","articleBody":"the `hashlib` package supports variable-length digests `SHAKE-128` and `SHAKE-256`. For those objects, `digest()` and `hexdigest()` both need to take a length parameter, without which they fail `missing required argument 'length' (pos 1)`. (other digest algorithms know their own output length and do not require (or accept) an argument to these functions).\n\nHowever, the typechecker insists that it's wrong to pass that `length` argument in this case:\n\n```\n0 dkg@bob:~/src/test$ cat hashlib-typing.py\n#!/usr/bin/python3\n\nimport hashlib\nh = hashlib.new(\"SHAKE-128\")\nh.update(b'')\nprint(h.hexdigest(16))\nprint(h.hexdigest())\n0 dkg@bob:~/src/test$ mypy --strict hashlib-typing.py\nhashlib-typing.py:6: error: Too many arguments for \"hexdigest\" of \"HASH\" [call-arg]\nFound 1 error in 1 file (checked 1 source file)\n1 dkg@bob:~/src/test$ ./hashlib-typing.py\n7f9c2ba4e88f827d616045507605853e\nTraceback (most recent call last):\n File \"/home/dkg/src/test/./hashlib-typing.py\", line 7, in \u003cmodule>\n print(h.hexdigest())\n ~~~~~~~~~~~^^\nTypeError: hexdigest() missing required argument 'length' (pos 1)\n1 dkg@bob:~/src/test$ \n```","author":{"url":"https://github.com/dkg","@type":"Person","name":"dkg"},"datePublished":"2026-10-05T14:42:14Z","url":"https://github.com/python/typeshed/issues/16480"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ebc3ff09-5092-4918-ae56-0f96272d39e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCDC:1F3799:28FBF50:35BA810:6B00099F |
| html-safe-nonce | 78c36c1539ce48102bd1c4934d44532bf2324ccd1c0c300d4492d185a77a0199 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0RDOjFGMzc5OToyOEZCRjUwOjM1QkE4MTA6NkIwMDA5OUYiLCJ2aXNpdG9yX2lkIjoiNzM5NDk1MjIxMjQ2NTU4NDU0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | dd3de424e131120c2ceeff1f0baf59d00d717971a0b37911e798a421b6f637a1 |
| hovercard-subject-tag | issue:5714023991 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/16480/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da72202b99817e2bdb6f82296f7a97e353faf4b418e380885c552710d34f5ad6/python/typeshed/issues/16480 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da72202b99817e2bdb6f82296f7a97e353faf4b418e380885c552710d34f5ad6/python/typeshed/issues/16480 |
| og:image:alt | the hashlib package supports variable-length digests SHAKE-128 and SHAKE-256. For those objects, digest() and hexdigest() both need to take a length parameter, without which they fail missing requi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dkg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width