fix(checker): catch UndefinedMethodException where needed

This commit is contained in:
2026-07-10 11:00:23 +02:00
parent e302ed2377
commit 00fdda5034
3 changed files with 20 additions and 8 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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(