From 15e642cc9076aea1de565af6648f139d9ba0784a Mon Sep 17 00:00:00 2001 From: David Hassell Date: Mon, 24 Feb 2025 08:27:21 +0000 Subject: [PATCH] add missing docstrings --- cfdm/data/abstract/filearray.py | 14 ++++++++++++-- cfdm/read_write/netcdf/netcdfread.py | 2 +- cfdm/test/test_docstring.py | 23 +++++++++++++++-------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cfdm/data/abstract/filearray.py b/cfdm/data/abstract/filearray.py index 297ad9850..6a8f15a8b 100644 --- a/cfdm/data/abstract/filearray.py +++ b/cfdm/data/abstract/filearray.py @@ -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"" - 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): diff --git a/cfdm/read_write/netcdf/netcdfread.py b/cfdm/read_write/netcdf/netcdfread.py index f7880617f..f8b6842ec 100644 --- a/cfdm/read_write/netcdf/netcdfread.py +++ b/cfdm/read_write/netcdf/netcdfread.py @@ -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 diff --git a/cfdm/test/test_docstring.py b/cfdm/test/test_docstring.py index aa80e00f6..10b022d4e 100644 --- a/cfdm/test/test_docstring.py +++ b/cfdm/test/test_docstring.py @@ -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."""