Open opk12 opened 8 months ago
Thank you @opk12 for opening this! This would be a good feature to add.
Out of curiosity, is this example from code you've seen/wrote? I'm trying to find examples of it in the wild using grep.app but it doesn't seem like a very common idiom.
(edited) Thank you for looking into it. I just wanted to throw an idea in the air, but I don't know if this is a common idiom in real-world code. I saw it in a student homework, which touches the file and then reads it.
def apri_file(nome):
if not os.path.exists(nome):
f = open(nome,"w")
f.close()
with open(nome, 'r') as route:
for row in csv.reader(route, delimiter="\t"):
...
This example could be refactored to not touch:
def apri_file(nome):
if os.path.exists(nome):
with open(nome, 'r') as route:
for row in csv.reader(route, delimiter="\t"):
...
else:
special case...
but as the warning is already implemented, I thought it just needs to be extended.
Has your issue already been fixed?
master
branch? 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
Extra Info
None