File crosshair-numpy-bound-method.patch of Package python-crosshair-tool
Index: crosshair_tool-0.0.102/crosshair/register_contract.py
===================================================================
--- crosshair_tool-0.0.102.orig/crosshair/register_contract.py 2026-01-19 21:47:44.000000000 +0100
+++ crosshair_tool-0.0.102/crosshair/register_contract.py 2026-03-28 00:46:48.148183654 +0100
@@ -41,6 +41,13 @@
return {k for (k, v) in sig.parameters.items() if v.default is Parameter.empty}
+def _strip_first_param(sig: Signature) -> Signature:
+ params = list(sig.parameters.values())
+ if not params:
+ return sig
+ return sig.replace(parameters=params[1:])
+
+
def _verify_signatures(
fn: Callable,
contract: ContractOverride,
@@ -221,6 +228,19 @@
# Weak references are not hashable: REGISTERED_CONTRACTS.get(fn) fails.
if isinstance(fn, ReferenceType):
return None
+ bound_fn = getattr(fn, "__func__", None)
+ if bound_fn is not None:
+ contract = REGISTERED_CONTRACTS.get(bound_fn)
+ if contract:
+ bound_self = getattr(fn, "__self__", None)
+ if bound_self is not None and not isinstance(bound_self, type):
+ return ContractOverride(
+ contract.pre,
+ contract.post,
+ [_strip_first_param(sig) for sig in contract.sigs],
+ contract.skip_body,
+ )
+ return contract
# Return the registered contract for the function, if any.
contract = REGISTERED_CONTRACTS.get(fn)
if contract: