Open daveisfera opened 8 months ago
I thought that maybe this was an issue with the cache, but I tried setting RUFF_NO_CACHE=true
from 0.1.5 and the problem still happens
I've tried playing around with different things when this happens to understand what's going on and the oddest thing I've noticed is that undoing the format and then editing the file usually doesn't change anything about the result. Here's an example:
This was the function at the end of a file I just edited:
@require_POST
def video(request: HttpRequest, stream_name: str) -> HttpResponse:
return _handle_data(request, stream_name, HlsType.video, UploadVideoForm, "data")
And it was truncated to this:
@require_POST
def video(request: HttpRequest, stream_name: str) -> Http
As mentioned, I undid the change from the format applied on save and then copied a second copy of the function just below it and saved again and it truncated to the same spot. I then did that 2 more times, so there were 4 copies of the function and it did the same thing. I added newlines above the function and after doing that a few times, it returned a result without the truncation and a warning about the multiple definitions of the function.
So it appears that the issue is happening on the reading of the file (or else the warning about the multiple definitions would have happened) and it appears that it's using the old length of the file when reading the data and that's what is causing the truncation
I've setup a file watcher that run
ruff --fix
andruff format
in a docker image. I've run just one of those commands to isolate the issue and have seen it happen when justruff --fix
orruff format
is running so it's happening with either command run separatelyHere's an example of the error output and when I look at the file, several characters from the last few lines have been removed (i.e. the file was truncated):
Here's the scripts that I use as the watcher (which I have setup in the same manner that
black
recommends):On a related note, I know there's a PyCharm plugin but I like running it in a container, because then CI and every developer machine is automagically kept in sync
Here's my
ruff.toml