-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
Cached runs crashes on typechecking .filter-kwargs with IndexError #827
Comments
I think I've hunted down the issue. I realised that on cached runs, any manager/queryset methods ended up with a
Which is the source of the index-error. There are no arguments there(all lists are empty). Also, when inspecting the
While on non-cached rounds it looks like this (which is what
I also extracted the mypy cache object for the Cache object for filter method "filter": {
".class": "SymbolTableNode",
"kind": "Mdef",
"node": {
".class": "FuncDef",
"arg_kinds": [
0,
2,
4
],
"arg_names": [
"self",
"args",
"kwargs"
],
"flags": [],
"fullname": "warehouse.models.ShipmentLineManager.filter",
"name": "filter",
"type": {
".class": "CallableType",
"arg_kinds": [
0,
2,
4
],
"arg_names": [
"self",
"args",
"kwargs"
],
"arg_types": [
{
".class": "Instance",
"args": [
{
".class": "TypeVarType",
"fullname": "django.db.models.manager._T",
"id": 1,
"name": "_T",
"upper_bound": "django.db.models.base.Model",
"values": [],
"variance": 1
}
],
"type_ref": "warehouse.models.ShipmentLineManager"
},
{
".class": "AnyType",
"missing_import_name": null,
"source_any": null,
"type_of_any": 2
},
{
".class": "AnyType",
"missing_import_name": null,
"source_any": null,
"type_of_any": 2
}
],
"bound_args": [],
"def_extras": {},
"fallback": "builtins.function",
"implicit": false,
"is_ellipsis_args": false,
"name": "filter of ShipmentLineManager",
"ret_type": {
".class": "Instance",
"args": [
{
".class": "TypeVarType",
"fullname": "django.db.models.manager._T",
"id": 1,
"name": "_T",
"upper_bound": "django.db.models.base.Model",
"values": [],
"variance": 1
}
],
"type_ref": "warehouse.managers.ShipmentLineQuerySet"
},
"type_guard": null,
"variables": []
}
},
"plugin_generated": true
} Right, so the cached object looks fine. But if one pays a bit extra attention, there's no
That's the reason we get a weird function-definition for e.g. django-stubs/mypy_django_plugin/lib/helpers.py Lines 409 to 412 in 220f0e4
Or, more precisely, it doesn't take into consideration that mypy always sets |
Bug report
Cached runs crashes on typechecking
QuerySet.filter()
-kwargsWhat's wrong
How is that should be
.filter
-kwargs should be properly typechecked on cached mypy runs.System information
python
version: 3.10.1django
version: 4.0.1mypy
version: 0.931django-stubs
version: 1.9.0 (but also failing onmaster
)django-stubs-ext
version: 0.3.1The text was updated successfully, but these errors were encountered: