-
Notifications
You must be signed in to change notification settings - Fork 636
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
Add Lintable.open()
a change detecting wrapper around Path.open()
#1865
Conversation
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.
If I understood correctly the goal was to enable Lintable to detect when the file on disk was modified since it cached its content.
If I would have wrote that, I would have probably look for checking the timestamp of the file and avoid checksum but maybe I am missing something. IMHO, i would have ensured that we would tell a Lintable when to reset cache manually.
For example for the generic formatter I would have looped on all Lintables and tell them to recache if needed, after the initial formatting stage. For Rules that can fix things, I would have just tell the affected Lintable to reload after saving the file.
@webknjaz WDYT?
The goal is to report which files were modified. Resetting the cache is a happy bonus. I really only care about recording (somewhere) that a file's contents were modified on disk. |
I also considered using filesize, but that would not catch updated quotes. If a set of double quotes gets replaced with single quotes, the file size will be the same, but I need to report that the contents have been modified. |
I created an alternate implementation in #1884 that does not use file content hashing. Closing in favor of #1884. |
We do not need to generate any diffs ourselves, there is git for that and we already rely on it for other features, like finding project root or progressive mode. |
As part of introducing formatting and transforms (see #1828), we need a way to detect changes in lintables.
By introducing a
Lintable.open()
, we can ensure thatThe goal of this PR is to achieve (1). (2) is a happy bonus that comes from tracking when the file gets modified.
So, I'm open to any alternative implementation that allows me to detect that the contents change.
Relevant scenarios to consider:
"
with'
.