Type error in 3rd party packages

What should I do in this scenario?

My error:
error: Argument 1 to "SevenZipFile" has incompatible type "RawIOBase"; expected "BinaryIO | str | Path" [arg-type]

This is the declaration in the package. Link

However I am using multivolumefile which is a RawIOBase. Link

The error makes sense, however I learned of this technique from their official documentation so I feel like I am making a mistake.

New users may only post 2 links, documentation link can be found here.

https://py7zr.readthedocs.io/en/latest/user_guide.html#extraction-from-multi-volume-archive

Advice is welcome.

How about import io and calling io.BinaryIO(...) on arg 1, the RawIOBase to wrap it?

Good point though. There is code in Py7zr to explicitly support multivolumefile.MultiVolume , and MultiVolume’s been a RawIOBAse for the last 5 years so maybe the Py7zr team would accept a PR that includes that in the type signature a bit, or adjusts the line that throws that error.

1 Like

Thanks for the tip, I will have to research this as I’m not familiar with the io library.

What do you think about casting or simply telling mypy to ignore the error? I’m asking because I’m apprehensive to modifying code in a way I don’t understand fully.

Assuming they’re going to fix it, “ignore type error” comments work nicely now that mypy (or some checkers) tell you when they’re no longer needed.