Skip to content

Commit

Permalink
fixup! fixup! Add better support for ManyToManyField's through model
Browse files Browse the repository at this point in the history
  • Loading branch information
flaeppe committed Sep 18, 2023
1 parent 7076dc3 commit f81debc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypy_django_plugin/transformers/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def get_m2m_arguments(
to = M2MTo(arg=to_arg, model=to_model, self=to_self)

through = None
if ctx.args[5]:
if len(ctx.args) > 5 and ctx.args[5]:
# 'ManyToManyField(..., through=)' was called
through_arg = CallArg(expr=ctx.args[5][0], kind=ctx.arg_kinds[5][0], name=ctx.arg_names[5][0])
through_model = get_model_info_from_call_arg(
Expand Down Expand Up @@ -324,7 +324,7 @@ def fill_model_args_for_many_to_many_field(
default_return_type: Instance,
django_context: DjangoContext,
) -> Instance:
if not ctx.args[0]:
if not ctx.args or not ctx.args[0]:
return default_return_type

args = get_m2m_arguments(ctx=ctx, model_info=model_info, django_context=django_context)
Expand Down

0 comments on commit f81debc

Please sign in to comment.