Skip to content

Fix #1855: fix check if file altered#1966

Closed
robsdedude wants to merge 1 commit into
PyCQA:mainfrom
robsdedude:fix/file-altered-check
Closed

Fix #1855: fix check if file altered#1966
robsdedude wants to merge 1 commit into
PyCQA:mainfrom
robsdedude:fix/file-altered-check

Conversation

@robsdedude

@robsdedude robsdedude commented Aug 21, 2022

Copy link
Copy Markdown
Contributor

When checking if a file got altered, leading and trailing white space is infact
relevant. Especially considering the existence of config options like
lines_before_imports and lines_after_imports.

Fixes #1855

@robsdedude

Copy link
Copy Markdown
Contributor Author

@timothycrosley it'd be great if you could find the time review this.

@robsdedude

Copy link
Copy Markdown
Contributor Author

@staticdev I'm sorry for the cold ping but I'd really like this to be moved forward :)

When checking if a file got altered, leading and trailing white space is infact
relevant. Especially considering the existence of config options like
`lines_before_imports` and `lines_after_imports`.
@robsdedude

Copy link
Copy Markdown
Contributor Author

Ah well. The .strip() calls I proposed to remove were introduced to fix #676. However, I'm pretty certain that simply stripping the output when checking for changes is not an appropriate fix for the issue as it introduces other issues the like one I'm trying to fix here. However, to get this PR to pass, I'd need to come up with a proper fix for 676 which turns out to be way more involved that I tough it was. I'm therefore abandoning this fix.

I think a proper fix for the linked issue would be to make sure that core.py::process properly splits import sections by not mixing them with other instructions (like the print statement in the issue's example).

@robsdedude robsdedude closed this Oct 19, 2025
@robsdedude robsdedude deleted the fix/file-altered-check branch October 21, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lines_before_import seems to not always work on files

1 participant