Skip to content

Commit 59b4d2e

Browse files
committed
add custom_lookups, custom_managers test folders
1 parent 5f6b4bf commit 59b4d2e

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

django-stubs/db/models/manager.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from django.db.models.base import Model
44
from django.db.models.query import QuerySet
55

66
_T = TypeVar("_T", bound=Model, covariant=True)
7+
_Self = TypeVar('_Self', bound='BaseManager')
78

89
class BaseManager(QuerySet[_T]):
910
creation_counter: int = ...
@@ -16,7 +17,7 @@ class BaseManager(QuerySet[_T]):
1617
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...
1718
def check(self, **kwargs: Any) -> List[Any]: ...
1819
@classmethod
19-
def from_queryset(cls, queryset_class: Any, class_name: Optional[Any] = ...): ...
20+
def from_queryset(cls: Type[_Self], queryset_class: Any, class_name: Optional[Any] = ...) -> Type[_Self]: ...
2021
@classmethod
2122
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
2223
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...

scripts/typecheck_tests.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# settings
3636
re.compile(r'Module has no attribute "[A-Z_]+"'),
3737
# attributes assigned to test functions
38-
re.compile(r'"Callable\[\[(Any(, )?)+\], Any\]" has no attribute'),
38+
re.compile(r'"Callable\[\[(Any(, )?)+(, VarArg\(Any\))?(, KwArg\(Any\))?\], Any\]" has no attribute'),
3939
# assign empty tuple
4040
re.compile(r'Incompatible types in assignment \(expression has type "Tuple\[\]", '
4141
r'variable has type "Tuple\[[A-Za-z, ]+\]"'),
@@ -70,6 +70,19 @@
7070
'builtin_server': [
7171
'has no attribute "getvalue"'
7272
],
73+
'custom_lookups': [
74+
'in base class "SQLFuncMixin"'
75+
],
76+
'custom_managers': [
77+
'_filter_CustomQuerySet',
78+
'_filter_CustomManager',
79+
re.compile(r'Cannot determine type of \'(abstract_persons|cars|plain_manager)\''),
80+
# TODO: remove after 'objects' and '_default_manager' are handled in the plugin
81+
'Incompatible types in assignment (expression has type "CharField", '
82+
+ 'base class "Model" defined the type as "Manager[Model]")',
83+
# TODO: remove after from_queryset() handled in the plugin
84+
'Invalid base class'
85+
],
7386
'csrf_tests': [
7487
'Incompatible types in assignment (expression has type "property", ' +
7588
'base class "HttpRequest" defined the type as "QueryDict")'
@@ -167,8 +180,8 @@
167180
'context_processors',
168181
'csrf_tests',
169182
'custom_columns',
170-
# TODO: 'custom_lookups',
171-
# TODO: 'custom_managers',
183+
'custom_lookups',
184+
'custom_managers',
172185
'custom_methods',
173186
'custom_migration_operations',
174187
'custom_pk',

0 commit comments

Comments
 (0)