Skip to content

Commit 12e25cf

Browse files
committed
Fix CI failures: staticmethod not callable and missing dunders
- Remove staticmethod wrapper from numpy on_import lambda since the value is stored as a slot attribute, not a class attribute - Add __call__, __iter__, __bool__ dunder methods to _coconut_lazy_module so Python's type-level dunder lookup works correctly (needed for lru_cache proxy on Python < 3.10 and general robustness) https://claude.ai/code/session_01KBLQLYTdfjLPaR2UJhgnkq
1 parent 67c8d55 commit 12e25cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coconut/compiler/templates/header.py_template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ class _coconut_lazy_module{object}:
3939
_coconut_lazy_module._coconut_base_setattr(self, name, value)
4040
else:
4141
_coconut.setattr(_coconut_lazy_module._coconut_base_getattr(self, "_coconut_load")(), name, value)
42+
def __call__(self, *args, **kwargs):
43+
return _coconut_lazy_module._coconut_base_getattr(self, "_coconut_load")()(*args, **kwargs)
44+
def __iter__(self):
45+
return _coconut.iter(_coconut_lazy_module._coconut_base_getattr(self, "_coconut_load")())
4246
def __dir__(self):
4347
try:
4448
return _coconut.dir(_coconut_lazy_module._coconut_base_getattr(self, "_coconut_load")())
4549
except _coconut.ImportError:
4650
return _coconut_lazy_module.__slots__
51+
def __bool__(self):
52+
return True
4753
@_coconut_wraps(_coconut_py_super)
4854
def _coconut_super(type=None, object_or_type=None):
4955
if type is None:
@@ -85,7 +91,7 @@ class _coconut{object}:{COMMENT.EVERYTHING_HERE_MUST_BE_COPIED_TO_STUB_FILE}
8591
typing.__getattr__ = _typing_getattr
8692
_typing_getattr = staticmethod(_typing_getattr)
8793
{set_zip_longest}
88-
numpy = _coconut_lazy_module("numpy", on_import=staticmethod(lambda np: _coconut.abc.Sequence.register(np.ndarray)))
94+
numpy = _coconut_lazy_module("numpy", on_import=lambda np: _coconut.abc.Sequence.register(np.ndarray))
8995
numpy_modules = {numpy_modules}
9096
xarray_modules = {xarray_modules}
9197
pandas_modules = {pandas_modules}

0 commit comments

Comments
 (0)