Skip to content

Commit b855310

Browse files
authored
Disable pylint 2.8 consider-using-with refactoring suggestion (#1244)
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.
1 parent 91e3648 commit b855310

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pygmt/figure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class Figure:
7979

8080
def __init__(self):
8181
self._name = unique_name()
82-
self._preview_dir = TemporaryDirectory(prefix=self._name + "-preview-")
82+
self._preview_dir = TemporaryDirectory( # pylint: disable=consider-using-with
83+
prefix=f"{self._name}-preview-"
84+
)
8385
self._activate_figure()
8486

8587
def __del__(self):
@@ -375,7 +377,7 @@ def _preview(self, fmt, dpi, as_bytes=False, **kwargs):
375377
If ``as_bytes=False``, this is the file name of the preview image
376378
file. Else, it is the file content loaded as a bytes string.
377379
"""
378-
fname = os.path.join(self._preview_dir.name, "{}.{}".format(self._name, fmt))
380+
fname = os.path.join(self._preview_dir.name, f"{self._name}.{fmt}")
379381
self.savefig(fname, dpi=dpi, **kwargs)
380382
if as_bytes:
381383
with open(fname, "rb") as image:

0 commit comments

Comments
 (0)