Skip to content

Commit

Permalink
move repeat doc config to conf
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckerns committed Feb 4, 2023
1 parent c5e1675 commit 95cb794
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 83 deletions.
13 changes: 6 additions & 7 deletions dill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from .__info__ import __version__, __author__, __doc__, __license__
except: # pragma: no cover
import os
import sys
import sys
parent = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
sys.path.append(parent)
# get distribution meta info
# get distribution meta info
from version import (__version__, __author__,
get_license_text, get_readme_as_rst)
__license__ = get_license_text(os.path.join(parent, 'LICENSE'))
Expand All @@ -24,9 +24,9 @@


from ._dill import (
Pickler, Unpickler,
check, copy, dump, dumps, load, loads, pickle, pickles, register,
DEFAULT_PROTOCOL, HIGHEST_PROTOCOL, CONTENTS_FMODE, FILE_FMODE, HANDLE_FMODE,
dump, dumps, load, loads, copy,
Pickler, Unpickler, register, pickle, pickles, check,
DEFAULT_PROTOCOL, HIGHEST_PROTOCOL, HANDLE_FMODE, CONTENTS_FMODE, FILE_FMODE,
PickleError, PickleWarning, PicklingError, PicklingWarning, UnpicklingError,
UnpicklingWarning,
)
Expand All @@ -42,8 +42,6 @@
# make sure "trace" is turned off
logger.trace(False)

from importlib import reload

objects = {}
# local import of dill._objects
#from . import _objects
Expand All @@ -68,6 +66,7 @@ def load_types(pickleable=True, unpickleable=True):
Returns:
None
"""
from importlib import reload
# local import of dill.objects
from . import _objects
if pickleable:
Expand Down
26 changes: 18 additions & 8 deletions dill/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
]

import re
import os
import sys
import warnings

Expand Down Expand Up @@ -128,7 +129,7 @@ def _restore_modules(unpickler, main_module):

#NOTE: 06/03/15 renamed main_module to main
def dump_module(
filename = str(TEMPDIR/'session.pkl'),
filename: Union[str, os.PathLike] = None,
module: Optional[Union[ModuleType, str]] = None,
refimported: bool = False,
**kwds
Expand All @@ -141,7 +142,8 @@ def dump_module(
module can then be restored with the function :py:func:`load_module`.
Parameters:
filename: a path-like object or a writable stream.
filename: a path-like object or a writable stream. If `None`
(the default), write to a named file in a temporary directory.
module: a module object or the name of an importable module. If `None`
(the default), :py:mod:`__main__` is saved.
refimported: if `True`, all objects identified as having been imported
Expand Down Expand Up @@ -223,6 +225,8 @@ def dump_module(
if hasattr(filename, 'write'):
file = filename
else:
if filename is None:
filename = str(TEMPDIR/'session.pkl')
file = open(filename, 'wb')
try:
pickler = Pickler(file, protocol, **kwds)
Expand All @@ -242,7 +246,7 @@ def dump_module(
return

# Backward compatibility.
def dump_session(filename=str(TEMPDIR/'session.pkl'), main=None, byref=False, **kwds):
def dump_session(filename=None, main=None, byref=False, **kwds):
warnings.warn("dump_session() has been renamed dump_module()", PendingDeprecationWarning)
dump_module(filename, module=main, refimported=byref, **kwds)
dump_session.__doc__ = dump_module.__doc__
Expand Down Expand Up @@ -307,7 +311,7 @@ def _identify_module(file, main=None):
raise UnpicklingError("unable to identify main module") from error

def load_module(
filename = str(TEMPDIR/'session.pkl'),
filename: Union[str, os.PathLike] = None,
module: Optional[Union[ModuleType, str]] = None,
**kwds
) -> Optional[ModuleType]:
Expand All @@ -325,7 +329,8 @@ def load_module(
and returned.
Parameters:
filename: a path-like object or a readable stream.
filename: a path-like object or a readable stream. If `None`
(the default), read from a named file in a temporary directory.
module: a module object or the name of an importable module;
the module name and kind (i.e. imported or non-imported) must
match the name and kind of the module stored at ``filename``.
Expand Down Expand Up @@ -419,6 +424,8 @@ def load_module(
if hasattr(filename, 'read'):
file = filename
else:
if filename is None:
filename = str(TEMPDIR/'session.pkl')
file = open(filename, 'rb')
try:
file = _make_peekable(file)
Expand Down Expand Up @@ -484,13 +491,13 @@ def load_module(
return main

# Backward compatibility.
def load_session(filename=str(TEMPDIR/'session.pkl'), main=None, **kwds):
def load_session(filename=None, main=None, **kwds):
warnings.warn("load_session() has been renamed load_module().", PendingDeprecationWarning)
load_module(filename, module=main, **kwds)
load_session.__doc__ = load_module.__doc__

def load_module_asdict(
filename = str(TEMPDIR/'session.pkl'),
filename: Union[str, os.PathLike] = None,
update: bool = False,
**kwds
) -> dict:
Expand All @@ -505,7 +512,8 @@ def load_module_asdict(
the loaded module is stored in the ``__session__`` attribute.
Parameters:
filename: a path-like object or a readable stream
filename: a path-like object or a readable stream. If `None`
(the default), read from a named file in a temporary directory.
update: if `True`, initialize the dictionary with the current state
of the module prior to loading the state stored at filename.
**kwds: extra keyword arguments passed to :py:class:`Unpickler()`
Expand Down Expand Up @@ -549,6 +557,8 @@ def load_module_asdict(
if hasattr(filename, 'read'):
file = filename
else:
if filename is None:
filename = str(TEMPDIR/'session.pkl')
file = open(filename, 'rb')
try:
file = _make_peekable(file)
Expand Down
22 changes: 20 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,26 @@
# extension config
github_project_url = "https://github.com/uqfoundation/dill"
autoclass_content = 'both'
autodoc_default_options = {
'members': True,
'undoc-members': True,
'private-members': True,
'special-members': True,
'show-inheritance': True,
'imported-members': True,
'exclude-members': (
'__dict__,'
'__slots__,'
'__weakref__,'
'__module__,'
'_abc_impl,'
'__init__,'
'__annotations__,'
'__dataclass_fields__,'
)
}
autodoc_typehints = 'description'
napoleon_include_init_with_doc = True
autodoc_typehints_format = 'short'
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_ivar = True
Expand All @@ -87,7 +105,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
67 changes: 9 additions & 58 deletions docs/source/dill.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,46 @@ detect module
-------------

.. automodule:: dill.detect
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members: ismethod, isfunction, istraceback, isframe, iscode, parent, reference, at, parents, children
.. :exclude-members: +ismethod, isfunction, istraceback, isframe, iscode, parent, reference, at, parents, children
logger module
-------------

.. automodule:: dill.logger
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
objtypes module
---------------

.. automodule:: dill.objtypes
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
pointers module
---------------

.. automodule:: dill.pointers
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
session module
---------------
--------------

.. automodule:: dill.session
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members: dump_session, load_session
.. :exclude-members: +dump_session, load_session
settings module
---------------

.. automodule:: dill.settings
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
source module
-------------

.. automodule:: dill.source
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
temp module
-----------

.. automodule:: dill.temp
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members:
.. :exclude-members: +
7 changes: 1 addition & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ dill package documentation
==========================

.. automodule:: dill
:members:
:undoc-members:
:private-members:
:special-members:
:show-inheritance:
:imported-members:
.. :exclude-members: +
.. toctree::
:maxdepth: 2
Expand Down
4 changes: 2 additions & 2 deletions docs/source/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ get_objgraph script
-------------------

.. automodule:: _get_objgraph
:members:
.. :exclude-members: +
undill script
--------------------

.. automodule:: _undill
:members:
.. :exclude-members: +

0 comments on commit 95cb794

Please sign in to comment.