-
Notifications
You must be signed in to change notification settings - Fork 11
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
Reduce use of tempfile (fix #25) #26
Conversation
Reviewer's Guide by SourceryThis pull request reduces the use of temporary files and modifies the behavior of file operations in the 'safer' library. The changes primarily affect the test suite and the initialization of the library's main class. File-Level Changes
Tips
|
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.
Hey @rec - I've reviewed your changes - here's some feedback:
Overall Comments:
- There appears to be a duplication in the test file. The assertions
assert len(before) + 1 == len(after)
andassert len(after.difference(before)) == 1
are repeated twice in a row. Please remove the duplicate lines.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟡 Security: 1 issue found
- 🟡 Testing: 4 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
The AI schtick wasn't bad and I pushed some consequent changes to clean things up. |
This looks reasonable to me, but your change on line 660:
Looks like it will mean that 607 will never be called:
That might be a reasonable thing to do. Also, this isn't necessarily a problem, but it is a behavior change: by using |
Ah, sorry, I should have written up the change like I said I was going to, but I got distracted by the AI code review! :-D Two very perceptive comments, thanks! Line 607 does still get called, exactly in the case where you have a stream which is not a file or a file handle (for example, a socket connection). EDIT: I just checked it by Indeed, I thought for a while about replicating the magic that mkstemp does! But then I realized the following: if you call I will emphasize this in the documentation (EDIT: I just did) but I'm just going to have a blanket prohibition on trying to write to the same file twice at the same time with In that case, the "fixed" temp file name is perfectly OK as there will never be collisions. |
Summary by Sourcery
Reduce the use of temporary files by refining the logic for handling temporary file creation and permissions. Fix test assertions to accurately reflect the number of temporary files created. Add a test to ensure consistent permissions for temporary files.
Bug Fixes:
Enhancements:
Tests: