-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: keep lock file eol #9468
fix: keep lock file eol #9468
Conversation
Could you please make the fix in |
tomlkit already fixed this, many times, I think. https://github.com/python-poetry/tomlkit/pulls?q=is%3Apr+line+ending+is%3Aclosed they even have test for this |
Well, if it was fixed in tomlkit, we wouldn't need this patch, right? For me, this sounds like a workaround at best. |
Actually, I'm not sure if this is a bug of tomlkit, or poetry didn't use it as expected. I guess tomlkit would expect users to read a toml file with (and personally I hope we just use Unix eol everywhere…) |
but you are right, this can be fiexd on both side. tomlkit could get line ending when |
/ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this has a negative impact on performance but I hope this is neglectable.
I still believe that this should be fixed in |
Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
I do not think that is possible because since #6562 we use #6562 suggests that there is a relevant performance impact:
Thus, maybe we should really check the timings and investigate the alternative approach. |
I agree, we can patch tomlkit, but it means tomlkit need to get EOL even using tomlfile.write, which is a bad idea. this only impact perf when it write lockfile, which mean only |
Good point. I think I will do some simple performance measurements later. We could basically implement part of the logic of https://github.com/python-poetry/tomlkit/pull/201/files by ourselves, just using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I measured the timing for Poetry itself, and the penalty for reading the lock file with tomlkit
is still about 0.7 s. Even though that is only done when the lock file is actually written, it still feels like a significant regression for an edge use case (i.e. keep line endings). IMO, we have two options:
- Just do not support this use case and write
\r\n
on Windows and\n
on Linux. You can still enforce one type of line endings in your git repo via .gitattributes (cf Preserve line breaks in poetry.lock (regression) #7527 (comment)) - Implement the "keep eol" logic from
tomlkit
by ourselves. See suggested change.
or, abandon the notion that a particular formatting-style for lockfiles is important and write them with tomli-w - which always uses I realise that I've suggested this in the past and I guess we likely still disagree on the merits of this - but I continue to favour eliminating tomlkit wherever it is possible to do so. |
to make the tomli-w comparison concrete I opened #9637 |
im OK with forcing lf, I just want eol don't change from lf to crlf or crlf to lf. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #1488 again
Resolves: #7527
#1488 once be fixed but it's broken again.
appearly
TOMLFile
need to callread
method to get line encoding, otherwise it just use default os eol.