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

Add missing docstrings #322

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 12 additions & 2 deletions cfdm/data/abstract/filearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,20 @@ def __getitem__(self, indices):
f"Must implement {self.__class__.__name__}.__getitem__"
) # pragma: no cover

def __repr__(self): # noqa: D105
def __repr__(self):
"""Called by the `repr` built-in function.

x.__repr__() <==> repr(x)

"""
return f"<CF {self.__class__.__name__}{self.shape}: {self}>"

def __str__(self): # noqa: D105
def __str__(self):
""""Called by the `str` built-in function.

x.__str__() <==> str(x)

"""
return f"{self.get_filename()}, {self.get_address()}"

def __dask_tokenize__(self):
Expand Down
2 changes: 1 addition & 1 deletion cfdm/read_write/netcdf/netcdfread.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from copy import deepcopy
from dataclasses import dataclass, field
from functools import reduce
from pprint import pformat
from math import log, nan, prod
from numbers import Integral
from pprint import pformat
from typing import Any
from uuid import uuid4

Expand Down
23 changes: 15 additions & 8 deletions cfdm/test/test_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,21 @@ def test_docstring(self):
if name.startswith("__") and not inspect.isfunction(f):
continue

if f.__doc__ is not None:
self.assertNotIn(
"{{",
f.__doc__,
f"\n\nCLASS: {klass}\n"
f"METHOD NAME: {name}\n"
f"METHOD: {f}",
)
self.assertIsNotNone(
f.__doc__,
f"\n\nCLASS: {klass}\n"
f"METHOD NAME: {name}\n"
f"METHOD: {f}",
)

# if f.__doc__ is not None:
self.assertNotIn(
"{{",
f.__doc__,
f"\n\nCLASS: {klass}\n"
f"METHOD NAME: {name}\n"
f"METHOD: {f}",
)

def test_docstring_package(self):
"""Test the docstring substitution of the package name."""
Expand Down
Loading