Fix callseq deduplication error, allow using Some|None=None args with no commutativity error, add ignore_basictypes_return for a ConversionPoint.from_fn
This commit is contained in:
@@ -90,7 +90,7 @@ class GraphWalker:
|
||||
if subg is not None:
|
||||
variant_subgraphs.add(subg)
|
||||
|
||||
consumed = frozenset(point.requires) & from_types
|
||||
consumed = (frozenset(point.requires) | frozenset(point.opt_args)) & from_types
|
||||
variant = CallgraphVariant(point, frozenset(variant_subgraphs), consumed)
|
||||
head = head.add_subgraph_variant(variant)
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ class ConversionPoint:
|
||||
def from_fn(cls,
|
||||
func: Callable,
|
||||
rettype: Optional[type] = None,
|
||||
type_remap: Optional[dict[str, type]] = None) -> list[ConversionPoint]:
|
||||
type_remap: Optional[dict[str, type]] = None,
|
||||
ignore_basictype_return: bool = False) -> list[ConversionPoint]:
|
||||
if type_remap is None:
|
||||
annot = get_type_hints(func)
|
||||
else:
|
||||
@@ -86,7 +87,7 @@ class ConversionPoint:
|
||||
if any(map(lambda x: fn_rettype_origin is x, cm_out_origins)) and is_context_manager_factory(func):
|
||||
fn_rettype = get_args(fn_rettype)[0]
|
||||
|
||||
if is_basic_type_annot(rettype):
|
||||
if not ignore_basictype_return and is_basic_type_annot(rettype):
|
||||
return []
|
||||
|
||||
ret = []
|
||||
@@ -96,7 +97,10 @@ class ConversionPoint:
|
||||
if len(tuple_unwrapped) > 0 and Ellipsis not in tuple_unwrapped:
|
||||
for t in tuple_unwrapped:
|
||||
if not is_basic_type_annot(t):
|
||||
ret += ConversionPoint.from_fn(func, rettype=t, type_remap=type_remap)
|
||||
ret += ConversionPoint.from_fn(func,
|
||||
rettype=t,
|
||||
type_remap=type_remap,
|
||||
ignore_basictype_return=ignore_basictype_return)
|
||||
|
||||
argtypes: list[list[type]] = []
|
||||
orig_args = extract_func_args(func, type_remap)
|
||||
|
||||
@@ -99,7 +99,7 @@ def deduplicate_callseq(conversion_models: list[ConversionRenderData]) -> list[C
|
||||
argument_changed = False
|
||||
found_model = False
|
||||
for m in deduplicated_conv_models:
|
||||
if not found_model and m == conv_model:
|
||||
if not found_model and m.funchash == conv_model.funchash:
|
||||
found_model = True
|
||||
|
||||
if found_model and m.inj_hash in argnames:
|
||||
|
||||
Reference in New Issue
Block a user