diff --git a/midas/checker/frames/column_groupby_methods.py b/midas/checker/frames/column_groupby_methods.py index 920a2b8..c92b08e 100644 --- a/midas/checker/frames/column_groupby_methods.py +++ b/midas/checker/frames/column_groupby_methods.py @@ -86,6 +86,9 @@ class ColumnGroupByMethodRegistry(MethodRegistry[Call]): # TODO: maybe better to filter arguments and pass some, in case the # return type depends on them + + # Don't catch UndefinedMethodException because all aggregation + # methods should be defined on columns too returns: Type = self.typer.call_method( location=call.location, call_expr=call.call_expr, diff --git a/midas/checker/frames/frame_groupby_methods.py b/midas/checker/frames/frame_groupby_methods.py index a2efba6..591c3ac 100644 --- a/midas/checker/frames/frame_groupby_methods.py +++ b/midas/checker/frames/frame_groupby_methods.py @@ -53,6 +53,8 @@ class FrameGroupByMethodRegistry(MethodRegistry[Call]): for column in call.groupby.frame.columns: with self.reporter.with_context(f"in column '{column.name}'"): column_groupby: ColumnGroupBy = ColumnGroupBy(column=column.type) + # Don't catch UndefinedMethodException because all aggregation + # methods should be defined on columns too result_type: Type = self.typer.call_method( location=call.location, call_expr=call.call_expr, diff --git a/midas/checker/python.py b/midas/checker/python.py index b2995d0..dd7eac8 100644 --- a/midas/checker/python.py +++ b/midas/checker/python.py @@ -772,14 +772,21 @@ class PythonTyper( match expr.callee: case p.GetExpr(object=obj, name=method): obj_type: Type = self.type_of(obj) - return self.call_method( - location=expr.location, - call_expr=expr, - obj=(obj, obj_type), - method_name=method, - positional=positional, - keywords=keywords, - ) + try: + return self.call_method( + location=expr.location, + call_expr=expr, + obj=(obj, obj_type), + method_name=method, + positional=positional, + keywords=keywords, + ) + except UndefinedMethodException: + self.reporter.error( + expr.location, + f"Unknown method {method} on type {obj_type}", + ) + return UnknownType() callee: Type = self.type_of(expr.callee) result: CallResult = self.dispatcher.get_result(