Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed PickleBuffers to hashlib #4362

Closed
crusaderky opened this issue Jul 25, 2020 · 4 comments · Fixed by #7683
Closed

Feed PickleBuffers to hashlib #4362

crusaderky opened this issue Jul 25, 2020 · 4 comments · Fixed by #7683
Labels
stubs: false positive Type checkers report false errors

Comments

@crusaderky
Copy link
Contributor

Python 3.8.5
mypy 0.782

h = hashlib.sha1()
pickle.dumps(obj, protocol=5, buffer_callback=h.update)

mypy output:
2: error: Argument "buffer_callback" to "dumps" has incompatible type "Callable[[Union[bytes, bytearray, memoryview]], None]"; expected "Optional[Callable[[PickleBuffer], Any]]"

Expected output:
No error

@srittau srittau added size-small stubs: false positive Type checkers report false errors labels Jul 25, 2020
@hatal175
Copy link
Contributor

hatal175 commented Apr 3, 2021

I think this needs python/typing#593 for a good fix. PickleBuffer implements the buffer protocol and not much more.

@srittau
Copy link
Collaborator

srittau commented Apr 6, 2021

We have _typeshed.ReadableBuffer as a stopgap measure.

@hatal175
Copy link
Contributor

hatal175 commented Apr 6, 2021

But ReadableBuffer doesn't contain PickleBuffer

@JelleZijlstra
Copy link
Member

@hatal175 but we could add it in the _typeshed stub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants