Eryk Sun added the comment:
The pathlib documentation of Path.rename() says "[o]n Unix, if target exists and is a file, it will be replaced silently if the user has permission". This leaves the behavior on Windows in question. The reader has to scroll down to the correspondence table to link to the documentation of os.rename() and presume that Path.rename() also raises FileExistsError for this case. The Path.rename() docs should just state upfront that "[o]n Windows, if target exists, FileExistsError will be raised".
----------
components: +Library (Lib)
title: Docs: the difference between rename and replace is not obvious -> Docs: the difference between Path.rename() and Path.replace() is not obvious
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.5, Python 3.6
_______________________________________
Python tracker
https://bugs.python.org/issue27886
_______________________________________