twisted / towncrier

Manage the release notes for your project.
https://towncrier.readthedocs.io
MIT License
755 stars 107 forks source link

Prefer pathlib for read/write operations #591

Closed jaraco closed 2 months ago

jaraco commented 2 months ago

Description

While working on #577, I noticed it might be nice to leverage pathlib for reading and writing files. This approach avoids adding nesting and with blocks by utilizing read_text and write_text.

This PR depends on #577 and should be rebased after merging that one.

Checklist

jaraco commented 2 months ago

Oh, this change fails on Python 3.9 and earlier due to the newline parameter only being added in that edition.

If this proposed transition is acceptable, I'd be tempted to wrap the offending call in a compatibility wrapper (something that would signal its removal after Python 3.9 support is dropped), but I'm not sure it's worth the effort.

jaraco commented 2 months ago

The coverage failure doesn't make any sense:

Name                       Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------------------
src/towncrier/_writer.py      25      0     10      1    97%   20->exit
----------------------------------------------------------------------
TOTAL                        677      0    321      1    99%

Does 20->exit mean that the coverage check wants to see an exception occur in the context in order to check both __exit__(None, None, None) and __exit__(type, val, ctx)? That's absurd and didn't need to be checked before. Or is it a bug in coverage, where it's failing to detect that the context is exited at all (which it must for the function to return)?

adiroiban commented 2 months ago

Thanks. If you are happy with this PR, feel free to merge.

jaraco commented 2 months ago

Thanks. If you are happy with this PR, feel free to merge.

I would merge, but something's wrong with credentials. I'm a member of towncrier-contributors, yet I have no option to merge. I've signed out and back in but yet can't merge. It says I need write access to merge.

image

adiroiban commented 2 months ago

Sorry. My bad. I set the wrong permissiosn for the team. I have merged it, but in the future you should be able to merge. Thanks again!