Repo/version: gplugins 2.0.1 on gdsfactory 9.34.2
What happened: Every submodule under gplugins/gmeep/ (write_sparameters_meep.py, write_sparameters_grating.py, ...) is named identically to the one function it exports, and gplugins/gmeep/__init__.py re-exports that function into the package namespace. The result is that import gplugins.gmeep.write_sparameters_grating as _wsg does not reliably bind _wsg to the module — it can bind to the function of the same name instead.
Steps to reproduce:
import gplugins.gmeep.write_sparameters_grating as _wsg
# This fails when _wsg is the function, not the module:
_wsg.get_simulation_grating_fiber = my_patched_version
# AttributeError: 'function' object has no attribute 'get_simulation_grating_fiber'
Expected: import gplugins.gmeep.write_sparameters_grating as _wsg should bind _wsg to the module object, so module-level names can be patched or inspected.
Actual: The import binds to the re-exported function. The only reliable way to reach the module object is to index sys.modules directly by the dotted string:
import sys
wsg = sys.modules["gplugins.gmeep.write_sparameters_grating"]
This workaround is undocumented anywhere in the library; the failure mode is a plain AttributeError with no hint that the import has bound to the wrong object.
Suggested fix: Either rename the re-exported function or the submodule so they do not collide, or document the collision and the sys.modules[...] workaround in the contributor documentation for anyone patching gmeep's internals.
Repo/version: gplugins 2.0.1 on gdsfactory 9.34.2
What happened: Every submodule under
gplugins/gmeep/(write_sparameters_meep.py,write_sparameters_grating.py, ...) is named identically to the one function it exports, andgplugins/gmeep/__init__.pyre-exports that function into the package namespace. The result is thatimport gplugins.gmeep.write_sparameters_grating as _wsgdoes not reliably bind_wsgto the module — it can bind to the function of the same name instead.Steps to reproduce:
Expected:
import gplugins.gmeep.write_sparameters_grating as _wsgshould bind_wsgto the module object, so module-level names can be patched or inspected.Actual: The import binds to the re-exported function. The only reliable way to reach the module object is to index
sys.modulesdirectly by the dotted string:This workaround is undocumented anywhere in the library; the failure mode is a plain
AttributeErrorwith no hint that the import has bound to the wrong object.Suggested fix: Either rename the re-exported function or the submodule so they do not collide, or document the collision and the
sys.modules[...]workaround in the contributor documentation for anyone patchinggmeep's internals.