File tree Expand file tree Collapse file tree 7 files changed +42
-2
lines changed Expand file tree Collapse file tree 7 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -151,3 +151,33 @@ def parse_order(data: Any) -> Literal["C", "F"]:
151151 if data in ("C" , "F" ):
152152 return cast (Literal ["C" , "F" ], data )
153153 raise ValueError (f"Expected one of ('C', 'F'), got { data } instead." )
154+
155+
156+ def _inherit_docstrings (cls : type [Any ]) -> type [Any ]:
157+ """
158+ Inherit docstrings from base class
159+
160+ Iterate over the methods of the class and if a method is missing a docstring,
161+ try to inherit one from a base class (ABC).
162+
163+ Parameters
164+ ----------
165+ cls : object
166+ the class to inherit docstrings from
167+
168+ Returns
169+ -------
170+ cls
171+ the class with updated docstrings
172+ """
173+ # Iterate over the methods of the class
174+ for name , method in cls .__dict__ .items ():
175+ # Skip if it's not a callable (method or function)
176+ if callable (method ):
177+ # Get the corresponding method from the base class (ABC)
178+ for base in cls .__bases__ :
179+ base_method = getattr (base , name , None )
180+ if base_method and not method .__doc__ :
181+ method .__doc__ = base_method .__doc__
182+ break
183+ return cls
Original file line number Diff line number Diff line change 11from zarr .storage .common import StoreLike , StorePath , make_store_path
22from zarr .storage .local import LocalStore
3+ from zarr .storage .logging import LoggingStore
34from zarr .storage .memory import MemoryStore
45from zarr .storage .remote import RemoteStore
56from zarr .storage .zip import ZipStore
67
78__all__ = [
89 "LocalStore" ,
10+ "LoggingStore" ,
911 "MemoryStore" ,
1012 "RemoteStore" ,
1113 "StoreLike" ,
Original file line number Diff line number Diff line change 99
1010from zarr .abc .store import ByteRangeRequest , Store
1111from zarr .core .buffer import Buffer
12- from zarr .core .common import concurrent_map
12+ from zarr .core .common import _inherit_docstrings , concurrent_map
1313
1414if TYPE_CHECKING :
1515 from collections .abc import AsyncGenerator , Iterable
@@ -66,6 +66,7 @@ def _put(
6666 return f .write (view )
6767
6868
69+ @_inherit_docstrings
6970class LocalStore (Store ):
7071 """
7172 Local file system store.
Original file line number Diff line number Diff line change 99
1010from zarr .abc .store import AccessMode , ByteRangeRequest , Store
1111from zarr .core .buffer import Buffer
12+ from zarr .core .common import _inherit_docstrings
1213
1314if TYPE_CHECKING :
1415 from collections .abc import AsyncGenerator , Generator , Iterable
1718 from zarr .core .common import AccessModeLiteral
1819
1920
21+ @_inherit_docstrings
2022class LoggingStore (Store ):
2123 """
2224 Store wrapper that logs all calls to the wrapped store.
Original file line number Diff line number Diff line change 44
55from zarr .abc .store import ByteRangeRequest , Store
66from zarr .core .buffer import Buffer , gpu
7- from zarr .core .common import concurrent_map
7+ from zarr .core .common import _inherit_docstrings , concurrent_map
88from zarr .storage ._utils import _normalize_interval_index
99
1010if TYPE_CHECKING :
1414 from zarr .core .common import AccessModeLiteral
1515
1616
17+ @_inherit_docstrings
1718class MemoryStore (Store ):
1819 """
1920 In-memory store for testing purposes.
Original file line number Diff line number Diff line change 66
77from zarr .abc .store import ByteRangeRequest , Store
88from zarr .core .buffer import Buffer
9+ from zarr .core .common import _inherit_docstrings
910from zarr .storage .common import _dereference_path
1011
1112if TYPE_CHECKING :
2425)
2526
2627
28+ @_inherit_docstrings
2729class RemoteStore (Store ):
2830 """
2931 A remote Store based on FSSpec
Original file line number Diff line number Diff line change 99
1010from zarr .abc .store import ByteRangeRequest , Store
1111from zarr .core .buffer import Buffer , BufferPrototype
12+ from zarr .core .common import _inherit_docstrings
1213
1314if TYPE_CHECKING :
1415 from collections .abc import AsyncGenerator , Iterable
1516
1617ZipStoreAccessModeLiteral = Literal ["r" , "w" , "a" ]
1718
1819
20+ @_inherit_docstrings
1921class ZipStore (Store ):
2022 """
2123 Storage class using a ZIP file.
You can’t perform that action at this time.
0 commit comments