News for hackers. Stuff that matters.
Re:Show HN: Refurb – A tool for refurbishing and modernizing... by blondin on Wednesday September 28, 2022 @01:47AM (#33004631)
why replace open() with the Path().read_text()? the open() API transcends Python and is almost ubiquitous. that suggestion seems frivolous.

while we are talking modern Python, the type hints fever seems to be receding. such a good thing in my opinion. i expected this tool to bark about types but am glad the author didn't go that far.

nice tool.

Re:Show HN: Refurb – A tool for refurbishing and modernizing... by dosisod on Wednesday September 28, 2022 @02:01AM (#33004708)
Something that I forgot to mention in the other answers similar to this is that the Path().read_text() check only applies if the open() block is a single line, and that line is only used to read the contents of the file. If you are doing other things in that block, no error will be emitted. I agree that open() is pretty ubiquitous, but in certain cases (ie, if I am already using a Path object), using read_text() is a nice one-liner.
Re:Show HN: Refurb – A tool for refurbishing and modernizing... by bityard on Wednesday September 28, 2022 @01:48PM (#33010910)
read_text() is simpler and _much_ clearer (and thus, Pythonic) when you're doing trivial file operations like reading the contents into a variable. Opening up a whole context manager is still an option when you have to do more complicated stuff to the file.