Skip to content

Commit

Permalink
Merge pull request #322 from davidhassell/main
Browse files Browse the repository at this point in the history
Add missing docstrings
  • Loading branch information
davidhassell authored Feb 24, 2025
2 parents 4020c84 + 15e642c commit 0870202
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
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

0 comments on commit 0870202

Please sign in to comment.