Skip to content

Commit

Permalink
PR comments and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arunjose696 committed Aug 14, 2024
1 parent a3a627a commit f788a20
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions modin/core/storage_formats/pandas/query_compiler_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"""
import functools
import inspect
from pandas.core.indexes.frozen import FrozenList
from types import FunctionType, MethodType
from typing import Any, Dict, Tuple, TypeVar

Expand Down Expand Up @@ -56,10 +57,13 @@ def cast_arg_to_current_qc(arg):
else:
return arg

if isinstance(arguments, tuple):
imutable_types = (FrozenList, tuple)
if isinstance(arguments, imutable_types):
args_type = type(arguments)
arguments = list(arguments)
arguments = cast_nested_args_to_current_qc_type(arguments, current_qc)
return tuple(arguments)

return args_type(arguments)
if isinstance(arguments, list):
for i in range(len(arguments)):
if isinstance(arguments[i], (list, dict)):
Expand Down Expand Up @@ -88,8 +92,6 @@ def apply_argument_cast():
def decorator(obj: Fn) -> Fn:
"""Decorate function or class to cast all arguments that are query compilers to the current query compiler"""
if isinstance(obj, type):
seen: Dict[Any, Any] = {}

all_attrs = dict(inspect.getmembers(obj))
all_attrs.pop("__abstractmethods__")

Expand All @@ -103,10 +105,7 @@ def decorator(obj: Fn) -> Fn:
if isinstance(
attr_value, (FunctionType, MethodType, classmethod, staticmethod)
):
try:
wrapped = seen[attr_value]
except KeyError:
wrapped = seen[attr_value] = apply_argument_cast()(attr_value)
wrapped = apply_argument_cast()(attr_value)
setattr(obj, attr_name, wrapped)
return obj # type: ignore [return-value]
elif isinstance(obj, classmethod):
Expand Down

0 comments on commit f788a20

Please sign in to comment.