Has your issue already been fixed?
The Bug
The following code:
#! /usr/bin/env python3
import os.path
path = "/tmp/tmpfile1"
if not os.path.exists(path):
# Missing FURB151: No warning
f = open(path, "w")
f.close()
# Warns as expected
open(path, "w").close()
Does not emit the Path.touch() warning for lines 8-9. It only warns for line 12.
$ refurb --enable-all a.py
a.py:6:8 [FURB141]: Replace `os.path.exists(x)` with `Path(x).exists()`
a.py:12:5 [FURB151]: Replace `open(x, "w").close()` with `Path(x).touch()`
Version Info
Refurb: v1.27.0
Mypy: v1.8.0
Python Version
Python 3.11.7
Config File
Extra Info
None
Has your issue already been fixed?
masterbranch? See the docs for instructions on how to setup a local build of Refurb.The Bug
The following code:
Does not emit the Path.touch() warning for lines 8-9. It only warns for line 12.
Version Info
Python Version
Python 3.11.7
Config File
# N/AExtra Info
None