sazary
Repos
9
Followers
6
Following
3

Events

issue comment
Mypy crash on querysets

same thing happened for me.

mypy output:

$ mypy --show-column-numbers --config-file ~/code/python/miare/mypy.ini --follow-imports=skip ~/code/python/miare/capacity_prediction/
[...]
/home/sazary/code/python/miare/capacity_prediction/services/utils/occasion_applier.py:23: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.991
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 4665, in accept
  File "mypy/nodes.py", line 1841, in accept
  File "mypy/checkexpr.py", line 410, in visit_call_expr
  File "mypy/checkexpr.py", line 530, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1181, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1264, in check_call
  File "mypy/checkexpr.py", line 1466, in check_callable_call
  File "mypy/checkexpr.py", line 1021, in apply_function_plugin
  File "/home/sazary/.virtualenvs/miare39/lib/python3.9/site-packages/mypy_django_plugin/transformers/querysets.py", line 149, in extract_proper_type_queryset_values_list
    assert isinstance(default_return_type, Instance)
AssertionError:
/home/sazary/code/python/miare/capacity_prediction/services/utils/occasion_applier.py:23: : note: use --pdb to drop into pdb

the part of my code that mypy crashes on (occasion_applier.py lines 22 & 23):

        for occasion in occasions:
            occasion_area_ids = list(occasion.areas.values_list('id', flat=True))

I don't use any custom manager for Occasion model, nor for Area. The related part is:

class Occasion(models.Model):
    [...]
    areas = models.ManyToManyField(to=DriverArea, related_name='+', verbose_name='مناطق')
    [...]

My mypy.ini file:

[mypy]
python_version = 3.9
ignore_missing_imports = True
show_traceback = True
incremental = True

plugins =
    mypy_django_plugin.main,
    mypy_drf_plugin.main
    ; numpy.typing.mypy_plugin

[mypy.plugins.django-stubs]
django_settings_module = biar.settings.development

versions:

django-stubs==1.13.0
django-stubs-ext==0.7.0
djangorestframework-stubs==1.7.0
mypy==0.991
mypy-extensions==0.4.3
Django==3.2.2

Python 3.9.15
OS: Ubuntu 22.04.1

monkey patching is enabled too.

Created at 1 week ago
Created at 1 week ago
Created at 2 weeks ago
started
Created at 1 month ago
started
Created at 1 month ago
Created at 1 month ago
issue comment
Add `ScrapeAndCompare` utility

@bwplotka i think we can resolve this now

Created at 1 month ago
delete branch
sazary delete branch golangci-lint
Created at 1 month ago