I use pathlib in my software for library development -
but unfortunately my travis matrix brakes, because on some older python versions (3.5 - 3.7)
the pathlib.Path is not compatible with the newest 3.8 Version.
for instance, following will work on python 3.8, but not on 3.6, 3.7 etc. :
>>> path_test_file = pathlib.Path('./tests/mytest.txt')
>>> path_test_file.unlink(missing_ok=True)
Is there a convenient way to upgrade the pathlib library via requirements.txt, pip, etc ?
I tried also to monkey-patch the pathlib of older versions, but failed miserably.
As @jakub points out, of course there are programmatic solutions for that, like :
if path_test_file.exits():
path_test_file.unlink()
# or:
try:
path_test_file.unlink()
except Exception:
pass
that is really all clear and does not need an answer - but I don't want to clutter my code like that.
I would rather like to include some module and monkey-patch pathlib.Path if needed, and leave all other code as it is - and still be compatible with older python versions.
Maybe I should bump up https://github.com/KenKundert/extended_pathlib/blob/master/extended_pathlib.py