You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DESCRIPTION:
Opening a file using with statement is preferred as function open implements the context manager protocol that releases the resource when it is outside of the with block. Not doing so requires you to manually release the resource.
BAD PRACTICE:
f = open('/tmp/.deepsource.toml', 'w')
f.write("config file.")
No f.close() statement: file may remain unaccessible
PREFERRED:
with open('/tmp/.deepsource.toml', 'w') as f:
f.write("config file.")
Use the with statement to open a file in these places:
/Open-Source-Catalog/blob/master/check-catalog.py#L4-L4
Open-Source-Catalog/blob/master/check-catalog.py#L8-L8
The text was updated successfully, but these errors were encountered:
DESCRIPTION:
Opening a file using with statement is preferred as function open implements the context manager protocol that releases the resource when it is outside of the with block. Not doing so requires you to manually release the resource.
BAD PRACTICE:
f = open('/tmp/.deepsource.toml', 'w')
f.write("config file.")
No
f.close()
statement: file may remain unaccessiblePREFERRED:
with open('/tmp/.deepsource.toml', 'w') as f:
f.write("config file.")
Use the with statement to open a file in these places:
/Open-Source-Catalog/blob/master/check-catalog.py#L4-L4
Open-Source-Catalog/blob/master/check-catalog.py#L8-L8
The text was updated successfully, but these errors were encountered: