From 05ea54e11921f78b9159c90c50f14e011e7eb433 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 18 Dec 2022 12:26:07 -0800 Subject: [PATCH] src/sage/misc/lazy_import.pyx: Codestyle fixes --- src/sage/misc/lazy_import.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx index 8c0566ee27f..6bf9365c348 100644 --- a/src/sage/misc/lazy_import.pyx +++ b/src/sage/misc/lazy_import.pyx @@ -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. @@ -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', @@ -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. @@ -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)