Skip to content

Commit 04b2065

Browse files
committed
- removal of code related to dataclass implementation
1 parent 82f809f commit 04b2065

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

ibis/common/annotations.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import dataclasses
43
import functools
54
import inspect
65
import types
@@ -92,7 +91,8 @@ def __str__(self):
9291
errors += f"\n `{name}`: {value!r} of type {type(value)} is not {pattern.describe()}"
9392

9493
sig = f"{self.func.__name__}{self.sig}"
95-
cause = str(self.__cause__).lstrip('bind_fn() ') if self.__cause__ else ""
94+
# remove the leading "_custom_bind_fn()" that comes from the custom bind function generated in SignatureBinder
95+
cause = str(self.__cause__).lstrip('_custom_bind_fn() ') if self.__cause__ else ""
9696

9797
return self.msg.format(sig=sig, call=call, cause=cause, errors=errors)
9898

@@ -347,10 +347,10 @@ def __init__(self, signature: Signature):
347347

348348
# build a new signature with default values replaced with generated variable names
349349
processed_signature = inspect.Signature(parameters=processed_params)
350-
self.bind_fn_str = f'def bind_fn{processed_signature}:\n return locals()'
350+
self.bind_fn_str = f'def _custom_bind_fn{processed_signature}:\n return locals()'
351351

352352
exec(compile(self.bind_fn_str, '<string>', 'exec'), namespace)
353-
self._bind_fn = namespace['bind_fn']
353+
self._bind_fn = namespace['_custom_bind_fn']
354354

355355
def __call__(self, *args, **kwargs):
356356
return self._bind_fn(*args, **kwargs)
@@ -581,7 +581,7 @@ def validate(self, func, args, kwargs):
581581
return this
582582

583583
def validate_fast(self, func, args, kwargs):
584-
"""Faster validation using internal dataclass to bind args/kwargs to names instead of Signature.bind."""
584+
"""Faster validation using custom bind function for this signature (instead of Signature.bind)."""
585585
try:
586586
bound_kwargs = self._binder_fn(*args, **kwargs)
587587
except TypeError as err:
@@ -647,18 +647,6 @@ def validate_return(self, func, value):
647647
)
648648

649649
return result
650-
651-
652-
class DefaultFactory:
653-
"""Helper to create default factories for dataclass fields."""
654-
655-
__slots__ = ("value",)
656-
657-
def __init__(self, value):
658-
self.value = value
659-
660-
def __call__(self):
661-
return self.value
662650

663651

664652
def annotated(_1=None, _2=None, _3=None, **kwargs):

0 commit comments

Comments
 (0)