We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e5e669a commit a28f2bbCopy full SHA for a28f2bb
record_api/core.py
@@ -210,6 +210,16 @@ def signature(fn):
210
return inspect.signature(fn)
211
212
213
+def safe_signature(fn):
214
+ """
215
+ If fn is hashable, cache it, otherwise dont use cached version
216
217
+ try:
218
+ hash(fn)
219
+ except Exception:
220
+ return inspect.signature(fn)
221
+ return signature(fn)
222
+
223
@dataclasses.dataclass
224
class Bound:
225
"""
@@ -236,7 +246,7 @@ def as_dict(self):
236
246
@classmethod
237
247
def create(cls, fn, args, kwargs) -> Optional[Bound]:
238
248
try:
239
- sig = signature(fn)
249
+ sig = safe_signature(fn)
240
250
except ValueError:
241
251
return None
242
252
0 commit comments