Skip to content

Commit

Permalink
Fix IndexError for custom queryset managers
Browse files Browse the repository at this point in the history
Sometimes Mypy crashes on this line with an IndexError.

This change builds on the change in
typeddjango#1786 by making further
use of the safer variable `typed_var`.

`typed_var` will equal `manager_instance.args` if
`manager_instance.args` is populated, but if it isn't it will have
another sensible value we can use instead.

Because that value should be populated, this prevents the crash.
  • Loading branch information
meshy committed Feb 8, 2024
1 parent e1184c7 commit 8b0890c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mypy_django_plugin/transformers/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _process_dynamic_method(
):
ret_type = _replace_type_var(ret_type, base_that_has_method.defn.type_vars[0].fullname, typed_var[0])
args_types = [
_replace_type_var(arg_type, base_that_has_method.defn.type_vars[0].fullname, manager_instance.args[0])
_replace_type_var(arg_type, base_that_has_method.defn.type_vars[0].fullname, typed_var[0])
for arg_type in args_types
]
if base_that_has_method.self_type:
Expand Down

0 comments on commit 8b0890c

Please sign in to comment.