RefExpr in determining model fullname not supported

This commit is contained in:
Maxim Kurnikov
2018-12-21 01:49:10 +03:00
parent 3c3e9305f4
commit 2f58cdae88
2 changed files with 36 additions and 5 deletions

View File

@@ -8,6 +8,23 @@ model_cls = apps.get_model('myapp', 'User')
reveal_type(model_cls) # E: Revealed type is 'Type[myapp.models.User]'
reveal_type(model_cls.objects) # E: Revealed type is 'django.db.models.manager.Manager[myapp.models.User]'
[file myapp/__init__.py]
[file myapp/models.py]
from django.db import models
class User(models.Model):
pass
[CASE registry_apps_get_model_passed_as_variables_not_supported]
from django.apps.registry import Apps
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from myapp.models import User
app_name = 'myapp'
model_name = 'User'
apps = Apps()
model_cls = apps.get_model(app_name, model_name)
reveal_type(model_cls) # E: Revealed type is 'Type[django.db.models.base.Model]'
[file myapp/__init__.py]
[file myapp/models.py]
from django.db import models
@@ -28,4 +45,4 @@ reveal_type(model_cls.objects) # E: Revealed type is 'django.db.models.manager.
[file myapp/models.py]
from django.db import models
class User(models.Model):
pass
pass