Disable pylint 2.8 consider-using-with refactoring suggestion
Each pygmt.Figure instance has an associated directory that
holds temporary preview PNG and/or PDF figure files. It's
not easy to use a with-statement since TemporaryDirectory
is called in the __init__ of the Figure class, so the pylint
recommendation is simply disabled here.
@@ -79,7 +79,9 @@ class Figure:
def __init__(self):
self._name = unique_name()
- self._preview_dir = TemporaryDirectory(prefix=self._name + "-preview-")
+ self._preview_dir = TemporaryDirectory( # pylint: disable=consider-using-with
+ prefix=f"{self._name}-preview-"
+ )
self._activate_figure()
def __del__(self):
@@ -375,7 +377,7 @@ class Figure:
If ``as_bytes=False``, this is the file name of the preview image
file. Else, it is the file content loaded as a bytes string.
"""
- fname = os.path.join(self._preview_dir.name, "{}.{}".format(self._name, fmt))
+ fname = os.path.join(self._preview_dir.name, f"{self._name}.{fmt}")
self.savefig(fname, dpi=dpi, **kwargs)
if as_bytes:
with open(fname, "rb") as image:
