[New Rule] Suggest exist_ok
for Path.mkdir
and os.makedirs
#172
Labels
enhancement
New feature or request
exist_ok
for Path.mkdir
and os.makedirs
#172
Explanation
The methods
Path.mkdir
andos.makedirs
will fail if the target directory already exists. One approach is use a try-except block to handle that issue gracefully. While this is caught by with rule SIM105, the proposed solution is suboptimal, as it requires an additional import, two lines and some nesting.Example
All the same applies to
p.mkdir
ifp
is apathlib.Path
.The text was updated successfully, but these errors were encountered: