Open
Conversation
for more information, see https://pre-commit.ci
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
What is this PR
Bug fix
Why is this PR needed?
Currently, attempting to save a file to a path that already exists raises a
FileExistsErrordue to validation logic invalidate_file_path. This makes it inconvenient to re-run code that writes outputs to the same file path, which is a common workflow in data analysis.Most scientific Python libraries allow overwriting files when writing, so the current behaviour violates user expectations.
What does this PR do?
This PR modifies
_file_is_writableinmovement.validators.filesto allow overwriting existing files.Specifically:
FileExistsErrorwhen the file already existsThis aligns the behaviour of
validate_file_path(..., permission="w")with standard Python file writing semantics (e.g.,open(..., "w")).References
Fixes #813
How has this PR been tested?
Manually tested saving functions that rely on
validate_file_path, including:save_poses.to_dlc_filesave_bboxes.to_via_tracks_fileVerified that:
FileExistsErrorIs this a breaking change?
No.
This change relaxes existing validation behaviour and does not remove or modify any public API. Existing workflows that previously succeeded will continue to work, and workflows that previously failed due to file existence will now succeed.
Does this PR require an update to the documentation?
No.
The change aligns behaviour with typical expectations for file writing, and no documentation currently guarantees that existing files must not be overwritten.