Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/misc/lazy_import.pyx: Codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Dec 18, 2022
1 parent 4acb9d7 commit 05ea54e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ def get_star_imports(module_name):
star_imports[module_name] = all
return all


def attributes(a):
"""
Return the private attributes of a :class:`LazyImport` object in a dictionary.
Expand All @@ -1172,10 +1173,10 @@ def attributes(a):
EXAMPLES::
sage: from sage.misc.lazy_import import attributes
sage: lazy_import("sage.all","foo")
sage: lazy_import("sage.all", "foo")
sage: attributes(foo)['_namespace'] is globals()
True
sage: D=attributes(foo)
sage: D = attributes(foo)
sage: del D['_namespace']
sage: D
{'_as_name': 'foo',
Expand All @@ -1195,6 +1196,7 @@ def attributes(a):
"_at_startup": b._at_startup,
"_deprecation": b._deprecation}


def clean_namespace(namespace=None):
"""
Adjust :class:`LazyImport` bindings in given namespace to refer to this actual namespace.
Expand Down Expand Up @@ -1226,13 +1228,14 @@ def clean_namespace(namespace=None):
cdef LazyImport w
if namespace is None:
namespace = inspect.currentframe().f_locals
for k,v in namespace.items():
for k, v in namespace.items():
if type(v) is LazyImport:
w = v
if w._namespace is not None and (w._namespace is not namespace or w._as_name != k):
namespace[k] = LazyImport(w._module, w._name, as_name=k, at_startup=w._at_startup,
namespace=namespace, deprecation=w._deprecation)


# Add support for _instancedoc_
from sage.misc.instancedoc import instancedoc
instancedoc(LazyImport)

0 comments on commit 05ea54e

Please sign in to comment.