Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ruff's pydocstyle (D) rules and remove docformatter #2925

Merged
merged 20 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix D105: Missing docstring in magic method
  • Loading branch information
seisman committed Dec 27, 2023
commit 1280a1c4869669aeb9bdb161b6a4e5b0474099b4
4 changes: 3 additions & 1 deletion pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def __init__(self):
self._activate_figure()

def __del__(self):
# Clean up the temporary directory that stores the previews
"""
Clean up the temporary directory that stores the previews.
"""
if hasattr(self, "_preview_dir"):
self._preview_dir.cleanup()

Expand Down
6 changes: 6 additions & 0 deletions pygmt/helpers/tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ def __init__(self, prefix="pygmt-", suffix=".txt"):
self.name = tmpfile.name

def __enter__(self):
"""
Do nothing but return the object.
"""
return self

def __exit__(self, *args):
"""
Remove the temporary file.
"""
if os.path.exists(self.name):
os.remove(self.name)

Expand Down
7 changes: 6 additions & 1 deletion pygmt/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ def __init__(self, **kwargs):
lib.call_module(module="set", args=arg_str)

def __enter__(self):
"""
Do nothing but return the object.
"""
return self

def __exit__(self, exc_type, exc_value, traceback):
# revert to initial values
"""
Revert the configurations to initial values.
seisman marked this conversation as resolved.
Show resolved Hide resolved
"""
arg_str = " ".join(
[f'{key}="{value}"' for key, value in self.old_defaults.items()]
)
Expand Down
3 changes: 3 additions & 0 deletions pygmt/tests/test_clib_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def __init__(self, name):
self._name = name

def __str__(self):
"""
String representation of the object.
"""
return self._name


Expand Down