Skip to content

Conversation

@mathstuf
Copy link
Contributor


Fixes: #342.

Copy link
Owner

@lucc lucc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far.

Can you please add a docstring and type hints like in the rest of the code.

If you have the time you could also migrate the pytest tests from the original atomicwrites repo to stdlib unittest framework. But I recognize that this is a bit more work. (Test would be nice though so if you do not have the time I will look into it)

And I added a commit which I would ask you to squash into the "revert" commit because I want to keep some of the nix code changes.

This partially reverts commit 10977b7.

Some other `nix` changes are preserved so that this just removes the
`atomicwrites` bits.
@mathstuf
Copy link
Contributor Author

I added some docstrings. I don't really know what typehints do with @contextlib.contextmanager, so I'll just use CI to figure that out…

@mathstuf mathstuf force-pushed the no-atomicwrites branch 2 times, most recently from 240c739 to 9e6842a Compare July 10, 2025 02:25
mathstuf added 2 commits July 9, 2025 22:30
Lifted from pimutils/khal#1393 (which I also authored). Note that `khal`
used `mode='wb'` everywhere while `khard` uses the `atomicwrites`
default mode of `w`.

Fixes: lucc#342
Seems it was due to something with atomicwrites?
@mathstuf
Copy link
Contributor Author

I didn't drag the tests over; I don't really have a modern Python dev set up to iterate on that rapidly.

@emtiu
Copy link

emtiu commented Jul 10, 2025

If I read the code correctly, there's only one single call to the atomic_write function. Could it be easier to just eliminate that call completely, and implement the write directly with functions from os?

@mathstuf
Copy link
Contributor Author

Not as a with statement at least. Making a context manager to handle exceptions and error handling logic keeps it tidy even with a single call site, IMO.

@mathstuf
Copy link
Contributor Author

To be more precise, open-coding it would push the actual "meat" of the logic in by 2 more indentations and decorate it with a dozen or so lines of "safety handling" noise (at least as far as reviewing the call site logic is concerned).

@emtiu
Copy link

emtiu commented Jul 10, 2025

I see, thanks for the explanation!

@emtiu emtiu mentioned this pull request Jul 12, 2025
@lucc
Copy link
Owner

lucc commented Jul 15, 2025

I migrated the original tests from atomicwrites. Some are still broken, maybe we can fix them or we might disable them.

@untitaker is it ok for you if I copy your MIT licensed tests into this GPL project (thus publishing a GPL version of the changed code)? See b6cce2a.

@mschilli87
Copy link

@lucc

@untitaker is it ok for you if I copy your MIT licensed tests into this GPL project (thus publishing a GPL version of the changed code)? See b6cce2a.

AFAIK you can include MIT licensed code in GPL licensed project without the need to re-license (and therefore with out approval of / consulting with the author of) that piece of code. Of course you'd have to leave the original copyright note in place.

@lucc lucc force-pushed the no-atomicwrites branch from 127d1d0 to 921782a Compare July 22, 2025 21:10
@lucc lucc merged commit 97c79f8 into lucc:main Jul 22, 2025
8 checks passed
@lucc
Copy link
Owner

lucc commented Jul 22, 2025

Thanks @mathstuf !

I removed the tests that I migrated. I will open a followup PR for that and wait for untitaker there.

@mathstuf mathstuf deleted the no-atomicwrites branch July 23, 2025 02:18
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.

dependency on atomicwrites

4 participants