Repository navigation
Conversation
| if not chunk: | ||
| break | ||
| chunks.append(chunk) | ||
| size -= len(chunk) |
There was a problem hiding this comment.
read_up_to reassigns size on each loop iteration, so the parameter no longer represents the original requested size.
Details
✨ AI Reasoning
This is Python code, and read_up_to repeatedly decrements its size parameter as the loop consumes chunks. That makes the original requested size unavailable under its original name while the function runs.
🔧 How do I fix it?
Create new local variables instead of reassigning parameters. Use different variable names to clearly distinguish between input and modified values.
Reply on this comment to give feedback or ignore the issue.
More info
|
|
||
|
|
||
| class PrefixedStream(io.RawIOBase): | ||
| """Serves bytes that were already read, then the rest of the stream""" |
There was a problem hiding this comment.
The PrefixedStream docstring only restates that it serves the prefix before the underlying stream, which is already apparent from the class and implementation.
| """Serves bytes that were already read, then the rest of the stream""" |
Details
✨ AI Reasoning
The class name and readinto implementation already show that this stream serves the prefix before reading the underlying stream. The docstring adds no reason or other context.
Reply on this comment to give feedback or ignore the issue.
More info
| attribute = getattr(self._stream, name) | ||
| if name == "read1": |
There was a problem hiding this comment.
getattr(self._stream, name) is unnecessary for loaded seek and tell calls, which return the corresponding _source method. Check that case before looking up the attribute on _stream.
Show fix
| attribute = getattr(self._stream, name) | |
| if name == "read1": | |
| if name in ("seek", "tell") and self._source is not None: | |
| return getattr(self._source, name) | |
| attribute = getattr(self._stream, name) | |
| if name == "read1": | |
Details
✨ AI Reasoning
When the source has already been loaded and the requested attribute is seek or tell, the method is returned from _source. Looking up the same attribute on _stream first does not contribute to that result and can prevent the intended return if the original stream lacks the attribute.
Reply on this comment to give feedback or ignore the issue.
More info
No description provided.