-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy Crashes with newest version of Django. #13005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This looks like an issue with https://github.com/typeddjango/django-stubs |
@AlexWaygood I will do that :) Sorry for the inconvenience. |
Great, no worries! I'll close this for now, but happy to reopen if I'm proven wrong and it is an issue with mypy core :) |
@AlexWaygood Sorry to reopen this, but is there a way for me to debug this further? Traceback (most recent call last):
File "mypy/dmypy_server.py", line 229, in serve
File "mypy/dmypy_server.py", line 272, in run_command
File "mypy/dmypy_server.py", line 331, in cmd_run
File "mypy/dmypy_server.py", line 388, in check
File "mypy/dmypy_server.py", line 423, in initialize_fine_grained
File "mypy/build.py", line 180, in build
File "mypy/build.py", line 256, in _build
File "mypy/build.py", line 2717, in dispatch
File "mypy/build.py", line 3048, in process_graph
File "mypy/build.py", line 3146, in process_stale_scc
File "mypy/build.py", line 2185, in type_check_first_pass
File "mypy/checker.py", line 314, in check_first_pass
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1005, in accept
File "mypy/checker.py", line 1785, in visit_class_def
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1074, in accept
File "mypy/checker.py", line 2047, in visit_block
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 819, in accept
File "mypy/checker.py", line 3748, in visit_decorator
File "mypy/checker.py", line 836, in check_func_item
File "mypy/checker.py", line 1021, in check_func_def
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1074, in accept
File "mypy/checker.py", line 2047, in visit_block
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1218, in accept
File "mypy/checker.py", line 3663, in visit_for_stmt
File "mypy/checker.py", line 436, in accept_loop
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1074, in accept
File "mypy/checker.py", line 2047, in visit_block
File "mypy/checker.py", line 422, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checker.py", line 420, in accept
File "mypy/nodes.py", line 1140, in accept
File "mypy/checker.py", line 2089, in visit_assignment_stmt
File "mypy/checker.py", line 2271, in check_assignment
File "mypy/checkexpr.py", line 3964, in accept
File "mypy/errors.py", line 844, in report_internal_error
File "mypy/checkexpr.py", line 3962, in accept
File "mypy/nodes.py", line 1713, in accept
File "mypy/checkexpr.py", line 288, in visit_call_expr
File "mypy/checkexpr.py", line 371, in visit_call_expr_inner
File "mypy/checkexpr.py", line 878, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 938, in check_call
File "mypy/checkexpr.py", line 1068, in check_callable_call
File "mypy/checkexpr.py", line 758, in apply_function_plugin
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/mypy_django_plugin/transformers/orm_lookups.py", line 42, in typecheck_queryset_filter
lookup_type = django_context.resolve_lookup_expected_type(ctx, model_cls, lookup_kwarg)
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/mypy_django_plugin/django/context.py", line 375, in resolve_lookup_expected_type
lookup_parts, field_parts, is_expression = query.solve_lookup_type(lookup)
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1217, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1658, in names_to_path
name = opts.pk.name
AttributeError: 'NoneType' object has no attribute 'name' I cannot for the live of me find out where it is, so it makes it super difficult to actually create a minimal repo. Is there any way mypy can help me debug here? It seems like a model makes problems, but I cant really see where or which. I sadly cannot share the repo, so I would love to give some other insight if possible with mypy.. Running: |
If you clone mypy and activate a virtual environment with an editable install, you could try adding And when all else fails, try randomly deleting files/classes/functions/whatever from your codebase until you can no longer reproduce the problem. When you get to that point, you'll have your minimal repro :) |
Thanks for the quick reply. I will try printing, maybe that will do something, otherwise we will leave it :) |
You could also try bisecting which specific commit in the |
That could be an idea too. I will read how to bisect then. File "mypy/checkexpr.py", line 758, in apply_function_plugin
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/mypy_django_plugin/transformers/orm_lookups.py", line 40, in typecheck_queryset_filter
lookup_type = django_context.resolve_lookup_expected_type(ctx, model_cls, lookup_kwarg)
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/mypy_django_plugin/django/context.py", line 375, in resolve_lookup_expected_type
lookup_parts, field_parts, is_expression = query.solve_lookup_type(lookup)
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1217, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
File "/Users/thorbenluepkes/work/newmarkets/venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1658, in names_to_path
name = opts.pk.name
AttributeError: 'NoneType' object has no attribute 'name' I tried printing in Ohter than that, how would i connect the local django-stubs that i am bisecting with my current project? |
Since the trace is pointing you towards the Django plugin, what if you clone it and do an editable install in your mypy env?
Then you should be able to breakpoint/print-debug in the plugin code, where your trace is showing you. |
Crash Report
AttributeError: 'NoneType' object has no attribute 'name'
Looks similar to typeddjango/django-stubs#625
Traceback
To Reproduce
django==4.0.5
mypy==0.960
django-stubs==1.12.0
pydantic==1.9.1
Instal these packages and run mypy
Your Environment
--pretty --show-error-codes
mypy.ini
(and other config files): ```3.10.2
Using a bash script to run
dmypy
Filters out some django-specific files, and exlucdes nodes modules and virtual env.
It is not an issue on version
0.931
and beforeThe text was updated successfully, but these errors were encountered: