mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 20:54:29 +08:00
RefExpr in determining model fullname not supported
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user