id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
14767 Fix import_statements for lazy imported objects Thierry Monteil Jason Grout "Here is an example:
{{{
sage: import_statements('NN')
from sage.misc.lazy_import import NN
sage: from sage.misc.lazy_import import NN
...
ImportError: cannot import name NN
}}}
That's because `NN` is a not-yet-resolved lazy imported object.
Solution: if the object is a `LazyImport` then get the corresponding
object with `._get_object`. With the patch applied:
{{{
sage: import_statements(NN)
from sage.rings.semirings.non_negative_integer_semiring import NN
sage: import_statements('NN')
from sage.rings.semirings.non_negative_integer_semiring import NN
}}}
A potential bonus feature would have been to set lazy=True by default for lazy imported object:
{{{
sage: import_statements(NN)
lazy_import('from sage.rings.semirings.non_negative_integer_semiring', 'NN')
}}}
but the idea was dropped." defect closed major sage-5.11 misc fixed days49 Vincent Delecroix sage-5.11.rc0 Vincent Delecroix Nicolas M. Thiéry N/A