mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-10-11 23:50:18 +08:00
add support for get_user_model(), fixes #16
This commit is contained in:
1 parent
2720b74242
commit
b7f7713c5a
5 files changed
+128
-28
No files matched your search
@@ -10,6 +10,7 @@ from mypy.semanal import SemanticAnalyzerPass2
|
||||
from mypy.types import AnyType, Instance, NoneTyp, TypeOfAny
|
||||
|
||||
from mypy_django_plugin import helpers
|
||||
from mypy_django_plugin.helpers import iter_over_assignments
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -55,16 +56,6 @@ class ModelClassInitializer(metaclass=ABCMeta):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def iter_over_assignments(klass: ClassDef) -> Iterator[Tuple[Lvalue, Expression]]:
|
||||
for stmt in klass.defs.body:
|
||||
if not isinstance(stmt, AssignmentStmt):
|
||||
continue
|
||||
if len(stmt.lvalues) > 1:
|
||||
# not supported yet
|
||||
continue
|
||||
yield stmt.lvalues[0], stmt.rvalue
|
||||
|
||||
|
||||
def iter_call_assignments(klass: ClassDef) -> Iterator[Tuple[Lvalue, CallExpr]]:
|
||||
for lvalue, rvalue in iter_over_assignments(klass):
|
||||
if isinstance(rvalue, CallExpr):
|
||||
|
||||
Reference in new issue
Block a user