Skip to content
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

tmp files filtered out before checking for matching tracked file #249

Closed
njhuffman opened this issue Dec 19, 2021 · 3 comments · Fixed by #255
Closed

tmp files filtered out before checking for matching tracked file #249

njhuffman opened this issue Dec 19, 2021 · 3 comments · Fixed by #255
Assignees
Labels
bug Something isn't working
Milestone

Comments

@njhuffman
Copy link
Collaborator

Noticed the problem when configuring Darker on VSCode. Running the formatting command explicitly works but formatting on save does not. As noted in other issues, the only difference in executed command is that formatting on save runs on a tmp file (*.hash.tmp) instead of the file directly. Support was added to check for these tmp files but the check for them happens after filtering out the file.

The root of the error I believe is in calling git_get_modified_files, which in turn calls should_reformat_file which only allows .py files. This happens before ever accounting for possible tmp files.

I will poke a bit and see if just adding the check to should_reformat_file is sufficient to get things working.

Software Versions

  • Darker: 1.3.2
  • Python: 3.9.9
  • Black: 21.12b0
  • Isort: 5.10.1
  • VSCode: 1.63.2
@njhuffman
Copy link
Collaborator Author

I think I solved the problem with a small change to should_reformat_file:
return path.exists() and get_rev1_path(path).suffix == ".py"
(plus appropriate changes to avoid circular imports). Not sure yet what other implications this might have.

@akaihola
Copy link
Owner

akaihola commented Jan 18, 2022

Thanks @njhuffman, I'll take a look at your fix to see if it's safe to apply. I've been wondering all along why format on save wouldn't work but never got around to actually finding the root cause since I tend to reformat using a keyboard shortcut.

@akaihola akaihola self-assigned this Jan 18, 2022
@akaihola akaihola added the bug Something isn't working label Jan 18, 2022
@akaihola akaihola added this to the 1.4.0 milestone Jan 18, 2022
@akaihola
Copy link
Owner

akaihola commented Feb 6, 2022

@njhuffman the fix is now in #255. I invited you as a collaborator to this repository. If you accept, I can mark #255 for you to review.

@akaihola akaihola modified the milestones: 1.4.0, 1.4.1 Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants