lazy_import: Muffle diagnostic messages for "at_startup"
mkoeppe opened this issue · 22 comments
When loading a modularized part of Sage instead of sage.all, we should suppress the second of these two messages:
if startup_guard and not self._at_startup:
print(f"Resolving lazy import {self._name} during startup")
elif self._at_startup and not startup_guard:
print(f"Option ``at_startup=True`` for lazy import {self._name} not needed anymore")
Also, instead of print, we should use warnings.warn.
Previous discussion:
CC: @tscrim @jhpalmieri @nthiery
Component: refactoring
Author: Matthias Koeppe
Branch/Commit: 4a8f409
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/32619
New commits:
7e7f5fe | sage.doctest.forker: Use sage.misc.lazy_import.ensure_startup_finished |
Author: Matthias Koeppe
Branch pushed to git repo; I updated commit sha1. New commits:
181e4a0 | src/sage/misc/lazy_import.pyx: Use warnings.warn instead of print |
Green bot => positive review.
Reviewer: Travis Scrimshaw
Branch pushed to git repo; I updated commit sha1. New commits:
bc2b707 | sage.misc.lazy_import.finish_startup: Fixup |
Branch pushed to git repo; I updated commit sha1. New commits:
9830e4e | src/sage/misc/lazy_import.pyx: Adjust doctest output to use of warnings.warn |
Branch pushed to git repo; I updated commit sha1. New commits:
dadfa07 | src/sage/misc/lazy_import.pyx: Fix markup of doctest output |
There still is one doctest failure in misc/lazy_import.pyx.
Branch pushed to git repo; I updated commit sha1. New commits:
98d2e9b | src/sage/misc/lazy_import.pyx: In test_fake_startup, also reset finish_startup_called |
Branch pushed to git repo; I updated commit sha1. New commits:
4a8f409 | src/sage/misc/lazy_import.pyx: Warnings suppress duplicates, so use a different import for the repeated test |
LGTM.
Thanks!
Changed branch from u/mkoeppe/lazy_import__muffle_diagnostic_messages_for__at_startup_ to 4a8f409