diff --git a/docs/conf.py b/docs/conf.py index b809fcc..84e8f56 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,6 +24,7 @@ autosummary_generate = True # Turn on sphinx.ext.autosummary autosummary_imported_members = True # autodoc_inherit_docstrings = True +autodoc_member_order = "groupwise" napoleon_include_init_with_doc = True napoleon_numpy_docstring = True viewcode_line_numbers = True diff --git a/pyproject.toml b/pyproject.toml index 389b047..2684827 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling", "numpy", "cloudpickle"] +requires = ["hatchling"] build-backend = "hatchling.build" [project] diff --git a/src/saveable_objects/_saveable_object.py b/src/saveable_objects/_saveable_object.py index 7c5dd63..b54087d 100644 --- a/src/saveable_objects/_saveable_object.py +++ b/src/saveable_objects/_saveable_object.py @@ -77,7 +77,9 @@ def name(self) -> Optional[str]: """ return self._get_name(self._path) - def _save(self, path: str, write_mode: Literal["w", "wb", "a", "ab", "x", "xb"] = "wb"): + def _save(self, + path: str, + write_mode: Literal["w", "wb", "a", "ab", "x", "xb"] = "wb"): """Saves the object to `path` using `write_mode`. Parameters @@ -213,7 +215,11 @@ def update_save(self, path: Optional[str] = None) -> bool: return True @classmethod - def _load(cls, file: IO, new_path: Optional[str] = None, strict_typing: bool = True) -> "SaveableObject": + def _load(cls, + file: IO, + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> "SaveableObject": """Loads an instance from the `file`. Parameters @@ -251,7 +257,11 @@ def _load(cls, file: IO, new_path: Optional[str] = None, strict_typing: bool = T instance.path = new_path return instance @classmethod - def load(cls, path: str, new_path: Optional[str] = None, strict_typing: bool = True) -> "SaveableObject": + def load(cls, + path: str, + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> "SaveableObject": """Loads a pickled instance. Parameters @@ -286,7 +296,11 @@ def load(cls, path: str, new_path: Optional[str] = None, strict_typing: bool = T with open(path, "rb") as file: return cls._load(file, new_path, strict_typing) @classmethod - def tryload(cls, path: Optional[str], new_path: Optional[str] = None, strict_typing: bool = True) -> "SaveableObject" | Literal[False]: + def tryload(cls, + path: Optional[str], + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> "SaveableObject" | Literal[False]: """Attempts to :meth:`load` from the specified `path`. If the loading fails then ``False`` is returned. @@ -349,7 +363,11 @@ def loadif(cls, *args, **kwargs) -> Tuple["SaveableObject", bool]: return instance, True return cls(*args, **kwargs), False @classmethod - def loadifparams(cls, *args, dependencies: dict = {}, **kwargs) -> Tuple["SaveableObject", bool]: + def loadifparams(cls, + *args, + dependencies: dict = {}, + **kwargs + ) -> Tuple["SaveableObject", bool]: """Attempts to :meth:`load` from a specified `path`. If the loading fails or no `path` is specified or the parameters do not match the saved parameters then a new instance of the object is generated with the diff --git a/src/saveable_objects/_saveable_object_3_7.py b/src/saveable_objects/_saveable_object_3_7.py index 283e2b5..1cbf52d 100644 --- a/src/saveable_objects/_saveable_object_3_7.py +++ b/src/saveable_objects/_saveable_object_3_7.py @@ -213,7 +213,11 @@ def update_save(self, path: Optional[str] = None) -> bool: return True @classmethod - def _load(cls, file: IO, new_path: Optional[str] = None, strict_typing: bool = True) -> "SaveableObject": + def _load(cls, + file: IO, + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> "SaveableObject": """Loads an instance from the `file`. Parameters @@ -251,7 +255,11 @@ def _load(cls, file: IO, new_path: Optional[str] = None, strict_typing: bool = T instance.path = new_path return instance @classmethod - def load(cls, path: str, new_path: Optional[str] = None, strict_typing: bool = True) -> "SaveableObject": + def load(cls, + path: str, + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> "SaveableObject": """Loads a pickled instance. Parameters @@ -286,7 +294,11 @@ def load(cls, path: str, new_path: Optional[str] = None, strict_typing: bool = T with open(path, "rb") as file: return cls._load(file, new_path, strict_typing) @classmethod - def tryload(cls, path: Optional[str], new_path: Optional[str] = None, strict_typing: bool = True) -> Union["SaveableObject", bool]: + def tryload(cls, + path: Optional[str], + new_path: Optional[str] = None, + strict_typing: bool = True + ) -> Union["SaveableObject", bool]: """Attempts to :meth:`load` from the specified `path`. If the loading fails then ``False`` is returned. @@ -349,7 +361,11 @@ def loadif(cls, *args, **kwargs) -> Tuple["SaveableObject", bool]: return instance, True return cls(*args, **kwargs), False @classmethod - def loadifparams(cls, *args, dependencies: dict = {}, **kwargs) -> Tuple["SaveableObject", bool]: + def loadifparams(cls, + *args, + dependencies: dict = {}, + **kwargs + ) -> Tuple["SaveableObject", bool]: """Attempts to :meth:`load` from a specified `path`. If the loading fails or no `path` is specified or the parameters do not match the saved parameters then a new instance of the object is generated with the diff --git a/src/saveable_objects/checkpointing/_checkpointing.py b/src/saveable_objects/checkpointing/_checkpointing.py index 8e0c1e0..7ae5b16 100644 --- a/src/saveable_objects/checkpointing/_checkpointing.py +++ b/src/saveable_objects/checkpointing/_checkpointing.py @@ -7,8 +7,8 @@ def failed(load_attempt: SaveableObject | bool | Tuple[SaveableObject, bool]) -> :meth:`.load() `, :meth:`.tryload() `, :meth:`.loadif() `, or - :meth:`.loadifparams() ` attempt - fails. + :meth:`.loadifparams() ` + attempt fails. Parameters ---------- @@ -43,8 +43,8 @@ def succeeded(load_attempt: SaveableObject | bool | Tuple[SaveableObject, bool]) :meth:`.load() `, :meth:`.tryload() `, :meth:`.loadif() `, or - :meth:`.loadifparams() ` attempt - succeeds. + :meth:`.loadifparams() ` + attempt succeeds. Parameters ---------- diff --git a/src/saveable_objects/checkpointing/_checkpointing_3_7.py b/src/saveable_objects/checkpointing/_checkpointing_3_7.py index 869563a..7bc3b50 100644 --- a/src/saveable_objects/checkpointing/_checkpointing_3_7.py +++ b/src/saveable_objects/checkpointing/_checkpointing_3_7.py @@ -7,8 +7,8 @@ def failed(load_attempt: Union[SaveableObject, bool, Tuple[SaveableObject, bool] :meth:`.load() `, :meth:`.tryload() `, :meth:`.loadif() `, or - :meth:`.loadifparams() ` attempt - fails. + :meth:`.loadifparams() ` + attempt fails. Parameters ---------- @@ -43,8 +43,8 @@ def succeeded(load_attempt: Union[SaveableObject, bool, Tuple[SaveableObject, bo :meth:`.load() `, :meth:`.tryload() `, :meth:`.loadif() `, or - :meth:`.loadifparams() ` attempt - succeeds. + :meth:`.loadifparams() ` + attempt succeeds. Parameters ----------