Split out of #16 (item 4).
Reproduction (verified 2026-09-26, config2py 0.1.54, Linux)
HOME=$(mktemp -d) python -c "import os, pathlib; import config2py; print(sorted(str(p.relative_to(os.environ['HOME'])) for p in pathlib.Path(os.environ['HOME']).rglob('*')))"
# ['.config', '.config/config2py', '.config/config2py/configs', '.config/config2py/configs/.config2py']
config2py/tools.py runs config_getter = simple_config_getter() and local_configs = get_configs_local_store() at module level, which create the folder and a marker file. This fails or surprises on read-only filesystems, sandboxed test runners and containers, and slows import config2py for callers who only need codecs or ConfigStore.
Why this was not changed unattended
config_getter, local_configs and configs are public, importable module attributes that dependents use directly. Making them lazy (module __getattr__) changes object identity and timing of the folder creation, which some dependents may rely on (they write into the folder right after import).
Proposed plan
- Replace the three module-level instances with a module-level
__getattr__ in config2py/tools.py (and re-export through config2py/__init__.py via its own __getattr__), building them on first access and caching them.
- Test: importing
config2py with HOME pointed at an empty temp dir creates nothing; first access to config2py.config_getter creates the folder.
- Run the dependents gate (
fleet_dependents.json) before landing.
Split out of #16 (item 4).
Reproduction (verified 2026-09-26, config2py 0.1.54, Linux)
config2py/tools.pyrunsconfig_getter = simple_config_getter()andlocal_configs = get_configs_local_store()at module level, which create the folder and a marker file. This fails or surprises on read-only filesystems, sandboxed test runners and containers, and slowsimport config2pyfor callers who only needcodecsorConfigStore.Why this was not changed unattended
config_getter,local_configsandconfigsare public, importable module attributes that dependents use directly. Making them lazy (module__getattr__) changes object identity and timing of the folder creation, which some dependents may rely on (they write into the folder right after import).Proposed plan
__getattr__inconfig2py/tools.py(and re-export throughconfig2py/__init__.pyvia its own__getattr__), building them on first access and caching them.config2pywithHOMEpointed at an empty temp dir creates nothing; first access toconfig2py.config_gettercreates the folder.fleet_dependents.json) before landing.