mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 04:34:29 +08:00
lint fixes
This commit is contained in:
@@ -21,7 +21,7 @@ from mypy.types import AnyType, Instance
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny, UnionType
|
||||
|
||||
from mypy_django_plugin.lib import fullnames, helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, fullnames, helpers
|
||||
|
||||
try:
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
from typing import OrderedDict, List, Optional, Dict, Set, Union
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
|
||||
from mypy import checker
|
||||
from mypy.checker import TypeChecker
|
||||
from mypy.nodes import MypyFile, TypeInfo, Var, MDEF, SymbolTableNode, GDEF, Expression
|
||||
from mypy.plugin import CheckerPluginInterface, FunctionContext, MethodContext, AttributeContext
|
||||
from mypy.types import Type as MypyType, Instance, TupleType, TypeOfAny, AnyType, TypedDictType
|
||||
from mypy.nodes import (
|
||||
GDEF, MDEF, Expression, MypyFile, SymbolTableNode, TypeInfo, Var,
|
||||
)
|
||||
from mypy.plugin import (
|
||||
AttributeContext, CheckerPluginInterface, FunctionContext, MethodContext,
|
||||
)
|
||||
from mypy.types import AnyType, Instance, TupleType
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypedDictType, TypeOfAny
|
||||
|
||||
from mypy_django_plugin.lib import helpers
|
||||
|
||||
@@ -49,10 +55,12 @@ def make_tuple(api: 'TypeChecker', fields: List[MypyType]) -> TupleType:
|
||||
return TupleType(fields, fallback=fallback)
|
||||
|
||||
|
||||
def make_oneoff_typeddict(api: CheckerPluginInterface, fields: 'OrderedDict[str, MypyType]',
|
||||
def make_oneoff_typeddict(api: CheckerPluginInterface, fields: 'Dict[str, MypyType]',
|
||||
required_keys: Set[str]) -> TypedDictType:
|
||||
object_type = api.named_generic_type('mypy_extensions._TypedDict', [])
|
||||
typed_dict_type = TypedDictType(fields, required_keys=required_keys, fallback=object_type)
|
||||
typed_dict_type = TypedDictType(fields, # type: ignore
|
||||
required_keys=required_keys,
|
||||
fallback=object_type)
|
||||
return typed_dict_type
|
||||
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@ from typing import (
|
||||
TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Optional, Union,
|
||||
)
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.related import RelatedField
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel
|
||||
from mypy.checker import TypeChecker
|
||||
from mypy.mro import calculate_mro
|
||||
from mypy.nodes import (
|
||||
Block, ClassDef, Expression, MemberExpr, MypyFile, NameExpr, StrExpr, SymbolNode,
|
||||
SymbolTable, SymbolTableNode, TypeInfo, Var,
|
||||
Block, ClassDef, Expression, MemberExpr, MypyFile, NameExpr, StrExpr, SymbolNode, SymbolTable, SymbolTableNode,
|
||||
TypeInfo, Var,
|
||||
)
|
||||
from mypy.semanal import SemanticAnalyzer
|
||||
from mypy.types import AnyType, Instance, NoneTyp
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny, UnionType
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from mypy_django_plugin.lib import fullnames
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -50,7 +50,8 @@ def lookup_fully_qualified_sym(fullname: str, all_modules: Dict[str, MypyFile])
|
||||
# nested class
|
||||
for parent_cls_name in parent_cls_name.split('.'):
|
||||
sym = sym_table.get(parent_cls_name)
|
||||
if sym is None:
|
||||
if (sym is None or sym.node is None
|
||||
or not isinstance(sym.node, TypeInfo)):
|
||||
return None
|
||||
sym_table = sym.node.names
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from typing import Union, Tuple, List, Optional, NamedTuple, cast
|
||||
from typing import List, NamedTuple, Optional, Tuple, Union, cast
|
||||
|
||||
from mypy.nodes import Argument, FuncDef, Var, TypeInfo
|
||||
from mypy.plugin import DynamicClassDefContext, ClassDefContext
|
||||
from mypy.nodes import Argument, FuncDef, TypeInfo, Var
|
||||
from mypy.plugin import ClassDefContext, DynamicClassDefContext
|
||||
from mypy.plugins.common import add_method
|
||||
from mypy.semanal import SemanticAnalyzer
|
||||
from mypy.types import Instance, CallableType, AnyType, TypeOfAny, PlaceholderType
|
||||
from mypy.types import AnyType, CallableType, Instance
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
|
||||
class IncompleteDefnException(Exception):
|
||||
@@ -39,7 +40,7 @@ def prepare_unannotated_method_signature(method_node: FuncDef) -> Tuple[List[Arg
|
||||
|
||||
|
||||
class SignatureTuple(NamedTuple):
|
||||
arguments: Optional[List[Argument]]
|
||||
arguments: List[Argument]
|
||||
return_type: Optional[MypyType]
|
||||
cannot_be_bound: bool
|
||||
|
||||
@@ -53,16 +54,14 @@ def analyze_callable_signature(api: SemanticAnalyzer, method_node: FuncDef) -> S
|
||||
for arg_name, arg_type, original_argument in zip(method_type.arg_names[1:],
|
||||
method_type.arg_types[1:],
|
||||
method_node.arguments[1:]):
|
||||
arg_type = api.anal_type(arg_type, allow_placeholder=True)
|
||||
if isinstance(arg_type, PlaceholderType):
|
||||
analyzed_arg_type = api.anal_type(arg_type)
|
||||
if analyzed_arg_type is None:
|
||||
unbound = True
|
||||
|
||||
var = Var(name=original_argument.variable.name,
|
||||
type=arg_type)
|
||||
type=analyzed_arg_type)
|
||||
var.set_line(original_argument.variable)
|
||||
|
||||
if isinstance(arg_type, PlaceholderType):
|
||||
unbound = True
|
||||
argument = Argument(variable=var,
|
||||
type_annotation=arg_type,
|
||||
initializer=original_argument.initializer,
|
||||
@@ -70,10 +69,10 @@ def analyze_callable_signature(api: SemanticAnalyzer, method_node: FuncDef) -> S
|
||||
argument.set_line(original_argument)
|
||||
arguments.append(argument)
|
||||
|
||||
ret_type = api.anal_type(method_type.ret_type, allow_placeholder=True)
|
||||
if isinstance(ret_type, PlaceholderType):
|
||||
analyzed_ret_type = api.anal_type(method_type.ret_type)
|
||||
if analyzed_ret_type is None:
|
||||
unbound = True
|
||||
return SignatureTuple(arguments, ret_type, unbound)
|
||||
return SignatureTuple(arguments, analyzed_ret_type, unbound)
|
||||
|
||||
|
||||
def copy_method_or_incomplete_defn_exception(ctx: ClassDefContext,
|
||||
@@ -103,15 +102,17 @@ def copy_method_or_incomplete_defn_exception(ctx: ClassDefContext,
|
||||
and name not in semanal_api.cur_mod_node.names):
|
||||
semanal_api.add_imported_symbol(name, sym, context=semanal_api.cur_mod_node)
|
||||
|
||||
arguments, return_type, unbound = analyze_callable_signature(semanal_api, method_node)
|
||||
arguments, analyzed_return_type, unbound = analyze_callable_signature(semanal_api, method_node)
|
||||
assert len(arguments) + 1 == len(method_node.arguments)
|
||||
if unbound:
|
||||
raise IncompleteDefnException(f'Signature of method {method_node.fullname!r} is not ready')
|
||||
|
||||
assert analyzed_return_type is not None
|
||||
|
||||
if new_method_name in ctx.cls.info.names:
|
||||
del ctx.cls.info.names[new_method_name]
|
||||
add_method(ctx,
|
||||
new_method_name,
|
||||
args=arguments,
|
||||
return_type=return_type,
|
||||
return_type=analyzed_return_type,
|
||||
self_type=self_type)
|
||||
|
||||
@@ -9,7 +9,6 @@ from mypy.options import Options
|
||||
from mypy.plugin import (
|
||||
AttributeContext, ClassDefContext, DynamicClassDefContext, FunctionContext, MethodContext, Plugin,
|
||||
)
|
||||
from mypy.semanal import dummy_context
|
||||
from mypy.types import Type as MypyType
|
||||
|
||||
import mypy_django_plugin.transformers.orm_lookups
|
||||
@@ -19,8 +18,9 @@ from mypy_django_plugin.transformers import (
|
||||
fields, forms, init_create, meta, querysets, request, settings,
|
||||
)
|
||||
from mypy_django_plugin.transformers.managers import (
|
||||
create_new_manager_class_from_from_queryset_method,
|
||||
create_manager_class_from_as_manager_method, instantiate_anonymous_queryset_from_as_manager)
|
||||
create_manager_class_from_as_manager_method, create_new_manager_class_from_from_queryset_method,
|
||||
instantiate_anonymous_queryset_from_as_manager,
|
||||
)
|
||||
from mypy_django_plugin.transformers.models import process_model_class
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def transform_model_class(ctx: ClassDefContext,
|
||||
if sym is not None and isinstance(sym.node, TypeInfo):
|
||||
helpers.get_django_metadata(sym.node)['model_bases'][ctx.cls.fullname] = 1
|
||||
else:
|
||||
if not ctx.api.final_iteration and not ctx.api.deferred:
|
||||
if not ctx.api.final_iteration:
|
||||
ctx.api.defer()
|
||||
return
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import fullnames, helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, fullnames, helpers
|
||||
|
||||
|
||||
def _get_current_field_from_assignment(ctx: FunctionContext, django_context: DjangoContext) -> Optional[Field]:
|
||||
|
||||
@@ -5,7 +5,7 @@ from mypy.types import CallableType, Instance, NoneTyp
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeType
|
||||
|
||||
from mypy_django_plugin.lib import sem_helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, sem_helpers
|
||||
|
||||
|
||||
def make_meta_nested_class_inherit_from_any(ctx: ClassDefContext) -> None:
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
from typing import Iterator, Tuple, Optional, Any, Dict
|
||||
from typing import Any, Dict, Iterator, Optional, Tuple
|
||||
|
||||
from mypy.nodes import (
|
||||
FuncDef, MemberExpr, NameExpr, RefExpr, StrExpr, TypeInfo,
|
||||
PlaceholderNode, SymbolTableNode, GDEF,
|
||||
CallExpr, Context, Decorator, OverloadedFuncDef, SymbolTable)
|
||||
GDEF, CallExpr, Context, Decorator, FuncDef, MemberExpr, NameExpr, OverloadedFuncDef, PlaceholderNode, RefExpr,
|
||||
StrExpr, SymbolTable, SymbolTableNode, TypeInfo,
|
||||
)
|
||||
from mypy.plugin import ClassDefContext, DynamicClassDefContext, MethodContext
|
||||
from mypy.semanal import SemanticAnalyzer, is_valid_replacement, is_same_symbol
|
||||
from mypy.types import AnyType, Instance, TypeOfAny, CallableType
|
||||
from mypy.semanal import SemanticAnalyzer, is_same_symbol, is_valid_replacement
|
||||
from mypy.types import AnyType, CallableType, Instance
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.typevars import fill_typevars
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
from mypy_django_plugin.lib import fullnames, sem_helpers, helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, fullnames, helpers, sem_helpers
|
||||
|
||||
|
||||
def iter_all_custom_queryset_methods(derived_queryset_info: TypeInfo) -> Iterator[Tuple[str, FuncDef]]:
|
||||
@@ -26,7 +26,7 @@ def generate_from_queryset_name(base_manager_info: TypeInfo, queryset_info: Type
|
||||
return base_manager_info.name + 'From' + queryset_info.name
|
||||
|
||||
|
||||
def resolve_callee_info_or_exception(ctx: DynamicClassDefContext) -> Optional[TypeInfo]:
|
||||
def resolve_callee_info_or_exception(ctx: DynamicClassDefContext) -> TypeInfo:
|
||||
callee = ctx.call.callee
|
||||
assert isinstance(callee, MemberExpr)
|
||||
assert isinstance(callee.expr, RefExpr)
|
||||
@@ -34,14 +34,14 @@ def resolve_callee_info_or_exception(ctx: DynamicClassDefContext) -> Optional[Ty
|
||||
callee_info = callee.expr.node
|
||||
if (callee_info is None
|
||||
or isinstance(callee_info, PlaceholderNode)):
|
||||
raise sem_helpers.IncompleteDefnException(f'Definition of base manager {callee_info.fullname} '
|
||||
raise sem_helpers.IncompleteDefnException(f'Definition of base manager {callee.fullname!r} '
|
||||
f'is incomplete.')
|
||||
|
||||
assert isinstance(callee_info, TypeInfo)
|
||||
return callee_info
|
||||
|
||||
|
||||
def resolve_passed_queryset_info_or_exception(ctx: DynamicClassDefContext) -> Optional[TypeInfo]:
|
||||
def resolve_passed_queryset_info_or_exception(ctx: DynamicClassDefContext) -> TypeInfo:
|
||||
api = sem_helpers.get_semanal_api(ctx)
|
||||
|
||||
passed_queryset_name_expr = ctx.call.args[0]
|
||||
@@ -51,13 +51,14 @@ def resolve_passed_queryset_info_or_exception(ctx: DynamicClassDefContext) -> Op
|
||||
if (sym is None
|
||||
or sym.node is None
|
||||
or isinstance(sym.node, PlaceholderNode)):
|
||||
raise sem_helpers.BoundNameNotFound(passed_queryset_name_expr.fullname)
|
||||
bound_name = passed_queryset_name_expr.fullname or passed_queryset_name_expr.name
|
||||
raise sem_helpers.BoundNameNotFound(bound_name)
|
||||
|
||||
assert isinstance(sym.node, TypeInfo)
|
||||
return sym.node
|
||||
|
||||
|
||||
def resolve_django_manager_info_or_exception(ctx: DynamicClassDefContext) -> Optional[TypeInfo]:
|
||||
def resolve_django_manager_info_or_exception(ctx: DynamicClassDefContext) -> TypeInfo:
|
||||
api = sem_helpers.get_semanal_api(ctx)
|
||||
|
||||
sym = api.lookup_fully_qualified_or_none(fullnames.MANAGER_CLASS_FULLNAME)
|
||||
@@ -132,7 +133,7 @@ def create_new_manager_class_from_from_queryset_method(ctx: DynamicClassDefConte
|
||||
|
||||
class_def_context = ClassDefContext(cls=new_manager_info.defn,
|
||||
reason=ctx.call, api=semanal_api)
|
||||
self_type = fill_typevars(new_manager_info)
|
||||
self_type = Instance(new_manager_info, [AnyType(TypeOfAny.explicit)])
|
||||
|
||||
try:
|
||||
for name, method_node in iter_all_custom_queryset_methods(queryset_info):
|
||||
@@ -219,7 +220,6 @@ def add_symbol_table_node(api: SemanticAnalyzer,
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def create_manager_class_from_as_manager_method(ctx: DynamicClassDefContext) -> None:
|
||||
semanal_api = sem_helpers.get_semanal_api(ctx)
|
||||
try:
|
||||
@@ -232,7 +232,7 @@ def create_manager_class_from_as_manager_method(ctx: DynamicClassDefContext) ->
|
||||
else:
|
||||
raise
|
||||
|
||||
generic_param = AnyType(TypeOfAny.explicit)
|
||||
generic_param: MypyType = AnyType(TypeOfAny.explicit)
|
||||
generic_param_name = 'Any'
|
||||
if (semanal_api.scope.classes
|
||||
and semanal_api.scope.classes[-1].has_base(fullnames.MODEL_CLASS_FULLNAME)):
|
||||
@@ -254,7 +254,7 @@ def create_manager_class_from_as_manager_method(ctx: DynamicClassDefContext) ->
|
||||
|
||||
class_def_context = ClassDefContext(cls=new_manager_info.defn,
|
||||
reason=ctx.call, api=semanal_api)
|
||||
self_type = fill_typevars(new_manager_info)
|
||||
self_type = Instance(new_manager_info, [AnyType(TypeOfAny.explicit)])
|
||||
|
||||
try:
|
||||
for name, method_node in iter_all_custom_queryset_methods(queryset_info):
|
||||
@@ -298,16 +298,18 @@ def instantiate_anonymous_queryset_from_as_manager(ctx: MethodContext) -> MypyTy
|
||||
assert isinstance(ctx.type.ret_type, Instance)
|
||||
queryset_info = ctx.type.ret_type.type
|
||||
|
||||
fullname = get_generated_manager_fullname(ctx.context,
|
||||
base_manager_info=django_manager_info,
|
||||
queryset_info=queryset_info)
|
||||
metadata = get_generated_managers_metadata(django_manager_info)
|
||||
if fullname not in metadata:
|
||||
raise ValueError(f'{fullname!r} is not present in generated managers list')
|
||||
gen_name = django_manager_info.name + 'From' + queryset_info.name
|
||||
gen_fullname = 'django.db.models.manager' + '.' + gen_name
|
||||
|
||||
module_name, _, class_name = metadata[fullname].rpartition('.')
|
||||
metadata = get_generated_managers_metadata(django_manager_info)
|
||||
if gen_fullname not in metadata:
|
||||
raise ValueError(f'{gen_fullname!r} is not present in generated managers list')
|
||||
|
||||
module_name, _, class_name = metadata[gen_fullname].rpartition('.')
|
||||
current_module = helpers.get_current_module(api)
|
||||
assert module_name == current_module.fullname
|
||||
|
||||
generated_manager_info = current_module.names[class_name].node
|
||||
assert isinstance(generated_manager_info, TypeInfo)
|
||||
|
||||
return Instance(generated_manager_info, [])
|
||||
|
||||
@@ -5,7 +5,7 @@ from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, helpers
|
||||
|
||||
|
||||
def _get_field_instance(ctx: MethodContext, field_fullname: str) -> MypyType:
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
from typing import List, Optional, Type, cast
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields import DateField, DateTimeField
|
||||
from django.db.models.fields.related import ForeignKey, OneToOneField
|
||||
from django.db.models.fields.reverse_related import (
|
||||
ManyToManyRel, ManyToOneRel, OneToOneRel,
|
||||
)
|
||||
from mypy.nodes import ARG_STAR2, Argument, FuncDef, TypeInfo, Var, SymbolTableNode, MDEF, GDEF
|
||||
from mypy.nodes import (
|
||||
ARG_STAR2, GDEF, MDEF, Argument, Context, FuncDef, SymbolTableNode, TypeInfo, Var,
|
||||
)
|
||||
from mypy.plugin import ClassDefContext
|
||||
from mypy.plugins import common
|
||||
from mypy.semanal import SemanticAnalyzer, dummy_context
|
||||
@@ -13,7 +16,6 @@ from mypy.types import AnyType, Instance
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
from django.db.models.fields import DateField, DateTimeField
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import fullnames, helpers, sem_helpers
|
||||
from mypy_django_plugin.transformers import fields
|
||||
@@ -71,47 +73,25 @@ class ModelClassInitializer:
|
||||
var.is_initialized_in_class = True
|
||||
|
||||
sym = SymbolTableNode(MDEF, var, plugin_generated=True)
|
||||
context = dummy_context()
|
||||
context: Optional[Context] = dummy_context()
|
||||
if force_replace_existing:
|
||||
context = None
|
||||
self.api.add_symbol_table_node(name, sym, context=context)
|
||||
|
||||
def add_new_class_for_current_module(self, name: str, bases: List[Instance],
|
||||
force_replace_existing: bool = False) -> Optional[TypeInfo]:
|
||||
force_replace_existing: bool = False) -> TypeInfo:
|
||||
current_module = self.api.cur_mod_node
|
||||
if not force_replace_existing and name in current_module:
|
||||
if not force_replace_existing and name in current_module.names:
|
||||
raise ValueError(f'Class {name!r} already defined for module {current_module.fullname!r}')
|
||||
|
||||
new_typeinfo = helpers.new_typeinfo(name,
|
||||
bases=bases,
|
||||
module_name=current_module.fullname)
|
||||
# sym = SymbolTableNode(GDEF, new_typeinfo,
|
||||
# plugin_generated=True)
|
||||
# context = dummy_context()
|
||||
# if force_replace_existing:
|
||||
# context = None
|
||||
|
||||
if name in current_module.names:
|
||||
del current_module.names[name]
|
||||
current_module.names[name] = SymbolTableNode(GDEF, new_typeinfo, plugin_generated=True)
|
||||
# current_module.defs.append(new_typeinfo.defn)
|
||||
# self.api.cur_mod_node.
|
||||
# self.api.leave_class()
|
||||
# added = self.api.add_symbol_table_node(name, sym, context=context)
|
||||
# self.api.enter_class(self.model_classdef.info)
|
||||
#
|
||||
# self.api.cur_mod_node.defs.append(new_typeinfo.defn)
|
||||
|
||||
# if not added and force_replace_existing:
|
||||
# return None
|
||||
return new_typeinfo
|
||||
|
||||
# current_module = self.api.modules[self.model_classdef.info.module_name]
|
||||
# context =
|
||||
# new_class_info = helpers.add_new_class_for_module(current_module,
|
||||
# name=name, bases=bases)
|
||||
# return new_class_info
|
||||
|
||||
def run(self) -> None:
|
||||
model_cls = self.django_context.get_model_class_by_fullname(self.model_classdef.fullname)
|
||||
if model_cls is None:
|
||||
@@ -193,7 +173,7 @@ class AddRelatedModelsId(ModelClassInitializer):
|
||||
|
||||
related_model_cls = self.django_context.get_field_related_model_cls(field)
|
||||
if related_model_cls is None:
|
||||
error_context = self.ctx.cls
|
||||
error_context: Context = self.ctx.cls
|
||||
field_sym = self.ctx.cls.info.get(field.name)
|
||||
if field_sym is not None and field_sym.node is not None:
|
||||
error_context = field_sym.node
|
||||
@@ -383,13 +363,8 @@ class AddRelatedManagers(ModelClassInitializer):
|
||||
bases = [parametrized_related_manager_type, default_manager_type]
|
||||
new_related_manager_info = self.add_new_class_for_current_module(name, bases,
|
||||
force_replace_existing=True)
|
||||
if new_related_manager_info is None:
|
||||
# wasn't added for some reason, defer
|
||||
if not self.api.final_iteration:
|
||||
self.api.defer()
|
||||
continue
|
||||
|
||||
self.add_new_node_to_model_class(related_manager_attr_name, Instance(new_related_manager_info, []))
|
||||
self.add_new_node_to_model_class(related_manager_attr_name,
|
||||
Instance(new_related_manager_info, []))
|
||||
|
||||
|
||||
class AddExtraFieldMethods(ModelClassInitializer):
|
||||
|
||||
@@ -4,7 +4,7 @@ from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import fullnames, helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, fullnames, helpers
|
||||
|
||||
|
||||
def typecheck_queryset_filter(ctx: MethodContext, django_context: DjangoContext) -> MypyType:
|
||||
|
||||
@@ -14,7 +14,7 @@ from mypy.types import TypeOfAny
|
||||
from mypy_django_plugin.django.context import (
|
||||
DjangoContext, LookupsAreUnsupported,
|
||||
)
|
||||
from mypy_django_plugin.lib import fullnames, helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, fullnames, helpers
|
||||
|
||||
|
||||
def _extract_model_type_from_queryset(queryset_type: Instance) -> Optional[Instance]:
|
||||
|
||||
@@ -3,7 +3,7 @@ from mypy.types import Instance
|
||||
from mypy.types import Type as MypyType
|
||||
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, helpers
|
||||
|
||||
|
||||
def set_auth_user_model_as_type_for_request_user(ctx: AttributeContext, django_context: DjangoContext) -> MypyType:
|
||||
|
||||
@@ -5,7 +5,7 @@ from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny, TypeType
|
||||
|
||||
from mypy_django_plugin.django.context import DjangoContext
|
||||
from mypy_django_plugin.lib import helpers, chk_helpers
|
||||
from mypy_django_plugin.lib import chk_helpers, helpers
|
||||
|
||||
|
||||
def get_user_model_hook(ctx: FunctionContext, django_context: DjangoContext) -> MypyType:
|
||||
|
||||
Reference in New Issue
Block a user