fix(checker): catch UndefinedMethodException where needed
This commit is contained in:
@@ -86,6 +86,9 @@ class ColumnGroupByMethodRegistry(MethodRegistry[Call]):
|
|||||||
|
|
||||||
# TODO: maybe better to filter arguments and pass some, in case the
|
# TODO: maybe better to filter arguments and pass some, in case the
|
||||||
# return type depends on them
|
# 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(
|
returns: Type = self.typer.call_method(
|
||||||
location=call.location,
|
location=call.location,
|
||||||
call_expr=call.call_expr,
|
call_expr=call.call_expr,
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class FrameGroupByMethodRegistry(MethodRegistry[Call]):
|
|||||||
for column in call.groupby.frame.columns:
|
for column in call.groupby.frame.columns:
|
||||||
with self.reporter.with_context(f"in column '{column.name}'"):
|
with self.reporter.with_context(f"in column '{column.name}'"):
|
||||||
column_groupby: ColumnGroupBy = ColumnGroupBy(column=column.type)
|
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(
|
result_type: Type = self.typer.call_method(
|
||||||
location=call.location,
|
location=call.location,
|
||||||
call_expr=call.call_expr,
|
call_expr=call.call_expr,
|
||||||
|
|||||||
@@ -772,14 +772,21 @@ class PythonTyper(
|
|||||||
match expr.callee:
|
match expr.callee:
|
||||||
case p.GetExpr(object=obj, name=method):
|
case p.GetExpr(object=obj, name=method):
|
||||||
obj_type: Type = self.type_of(obj)
|
obj_type: Type = self.type_of(obj)
|
||||||
return self.call_method(
|
try:
|
||||||
location=expr.location,
|
return self.call_method(
|
||||||
call_expr=expr,
|
location=expr.location,
|
||||||
obj=(obj, obj_type),
|
call_expr=expr,
|
||||||
method_name=method,
|
obj=(obj, obj_type),
|
||||||
positional=positional,
|
method_name=method,
|
||||||
keywords=keywords,
|
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)
|
callee: Type = self.type_of(expr.callee)
|
||||||
result: CallResult = self.dispatcher.get_result(
|
result: CallResult = self.dispatcher.get_result(
|
||||||
|
|||||||
Reference in New Issue
Block a user