Skip to content

AssertionError when using models.Manager #373

@dmwyatt

Description

@dmwyatt

Bug report

What's wrong

I can't seem to create a minimal example demonstrating this, but I'm getting this on one of my projects.

If I change a custom queryset to become a custom manager by changing what it inherits from and changing objects = CustomQuerySet.as_manager() to objects = CustomManager() I get the following.

Traceback (most recent call last):
  File "c:\users\dusti\.pyenv\pyenv-win\versions\3.8.0-amd64\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
    exec(code, run_globals)
  File "mypy\semanal.py", line 4679, in accept
  File "mypy\nodes.py", line 939, in accept
  File "mypy\semanal.py", line 1001, in visit_class_def
  File "mypy\semanal.py", line 1078, in analyze_class
  File "mypy\semanal.py", line 1087, in analyze_class_body_common
  File "mypy\semanal.py", line 1147, in apply_class_plugin_hooks
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\main.py", line 37, in transform_model_class
    process_model_class(ctx, django_context)
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\transformers\models.py", line 357, in process_model_class
    initializer_cls(ctx, django_context).run()
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\transformers\models.py", line 71, in run
    self.run_with_model_cls(model_cls)
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\transformers\models.py", line 230, in run_with_model_cls
    custom_manager_type = self.create_new_model_parametrized_manager(custom_model_manager_name,
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\transformers\models.py", line 183, in create_new_model_parametrized_manager
    helpers.copy_method_to_another_class(new_cls_def_context,
  File "c:\users\dusti\appdata\local\pypoetry\cache\virtualenvs\vehicles-caet0sxz-py3.8\lib\site-packages\mypy_django_plugin\lib\helpers.py", line 346, in copy_method_to_another_class
    assert bound_return_type is not None
AssertionError:
  • OS: Win10
  • python version: 3.8
  • django version: 3.0.6
  • mypy version: .770
  • django-stubs version: 1.5.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions