Off topic for the PR, but a couple of those might benefit from slight reorganization - instead of
with open(...) as file:
s = do_work()
file.write(s)
you could refactor as
s = do_work()
with open(...) as file:
file.write(s)
and that will have the benefit that a failure in do_work() won't leave a file around. That'd make sense if such a failure is more likely than a problem opening the file.
Actually, there's also pathlib.Path(...).write_text(...) or write_bytes(...) that will do the latter without the with noise.
Off topic for the PR, but a couple of those might benefit from slight reorganization - instead of
you could refactor as
and that will have the benefit that a failure in
do_work()
won't leave a file around. That'd make sense if such a failure is more likely than a problem opening the file.Actually, there's also
pathlib.Path(...).write_text(...)
orwrite_bytes(...)
that will do the latter without thewith
noise.Originally posted by @jennifer-richards in https://github.com/ietf-tools/xml2rfc/pull/1093#pullrequestreview-1856924199