From 87815de0db1e43ba016042da6a4d616cfe489b70 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Tue, 3 Mar 2026 20:58:24 -0800 Subject: [PATCH 1/4] Allow disabled eager loading with EAGER_IMPORT=0 --- README.md | 2 +- src/lazy_loader/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 17c255e..392f2d8 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ detail](https://scientific-python.org/specs/spec-0001/#type-checkers). With lazy loading, missing imports no longer fail upon loading the library. During development and testing, you can set the `EAGER_IMPORT` -environment variable to disable lazy loading. +environment variable to a value other than "0" to disable lazy loading. ### External libraries diff --git a/src/lazy_loader/__init__.py b/src/lazy_loader/__init__.py index 0b0243e..d9de6cd 100644 --- a/src/lazy_loader/__init__.py +++ b/src/lazy_loader/__init__.py @@ -92,7 +92,8 @@ def __getattr__(name): def __dir__(): return __all__.copy() - if os.environ.get("EAGER_IMPORT", ""): + eager_import = os.environ.get("EAGER_IMPORT", "") != "0" + if eager_import: for attr in set(attr_to_modules.keys()) | submodules: __getattr__(attr) From 16acc44bb9351c8306ac71fd543939a0b5a21b81 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 4 Mar 2026 00:14:25 -0800 Subject: [PATCH 2/4] Allow EAGER_IMPORT="" to disable it Co-authored-by: Chris Markiewicz --- src/lazy_loader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lazy_loader/__init__.py b/src/lazy_loader/__init__.py index d9de6cd..319166f 100644 --- a/src/lazy_loader/__init__.py +++ b/src/lazy_loader/__init__.py @@ -92,7 +92,7 @@ def __getattr__(name): def __dir__(): return __all__.copy() - eager_import = os.environ.get("EAGER_IMPORT", "") != "0" + eager_import = os.environ.get("EAGER_IMPORT", "") not in ("0", "") if eager_import: for attr in set(attr_to_modules.keys()) | submodules: __getattr__(attr) From 0a9187b188a73c8a6390e5bce7d4e05242ec4ef7 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 4 Mar 2026 00:21:28 -0800 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 392f2d8..bf4ee0b 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ detail](https://scientific-python.org/specs/spec-0001/#type-checkers). With lazy loading, missing imports no longer fail upon loading the library. During development and testing, you can set the `EAGER_IMPORT` -environment variable to a value other than "0" to disable lazy loading. +environment variable to "1" or "true" to disable lazy loading ("0" or "" enables lazy loading). ### External libraries From 4aead86ebd5cf528d0acc4bac5b77b37d6397cd3 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 4 Mar 2026 02:00:48 -0800 Subject: [PATCH 4/4] Tiny clarification --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf4ee0b..ab35b98 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ detail](https://scientific-python.org/specs/spec-0001/#type-checkers). With lazy loading, missing imports no longer fail upon loading the library. During development and testing, you can set the `EAGER_IMPORT` -environment variable to "1" or "true" to disable lazy loading ("0" or "" enables lazy loading). +environment variable to "1" or "true" to disable lazy loading ("0" or "" re-enables lazy loading). ### External libraries