mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 16:27:09 +08:00
Fix CI (#1108)
* Fix CI
* Fix CI
* Fix CI
* Fix CI
* APply black
* APply black
* Fix mypy
* Fix mypy errors in django-stubs
* Fix format
* Fix plugin
* Do not patch builtins by default
* Fix mypy
* Only run mypy on 3.10 for now
* Only run mypy on 3.10 for now
* WHAT THE HELL
* Enable strict mode in mypy
* Enable strict mode in mypy
* Fix tests
* Fix tests
* Debug
* Debug
* Fix tests
* Fix tests
* Add TYPE_CHECKING debug
* Caching maybe?
* Caching maybe?
* Try explicit `${{ matrix.python-version }}`
* Remove debug
* Fix typing
* Finally
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import TYPE_CHECKING, Optional, Tuple, Union, cast
|
||||
from typing import TYPE_CHECKING, Any, Optional, Tuple, Union, cast
|
||||
|
||||
from django.db.models.fields import AutoField, Field
|
||||
from django.db.models.fields.related import RelatedField
|
||||
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
||||
|
||||
def _get_current_field_from_assignment(
|
||||
ctx: FunctionContext, django_context: DjangoContext
|
||||
) -> Optional[Union[Field, ForeignObjectRel, "GenericForeignKey"]]:
|
||||
) -> Optional[Union["Field[Any, Any]", ForeignObjectRel, "GenericForeignKey"]]:
|
||||
outer_model_info = helpers.get_typechecker_api(ctx).scope.active_class()
|
||||
if outer_model_info is None or not helpers.is_model_subclass_info(outer_model_info, django_context):
|
||||
return None
|
||||
@@ -42,7 +42,7 @@ def _get_current_field_from_assignment(
|
||||
return current_field
|
||||
|
||||
|
||||
def reparametrize_related_field_type(related_field_type: Instance, set_type, get_type) -> Instance:
|
||||
def reparametrize_related_field_type(related_field_type: Instance, set_type: MypyType, get_type: MypyType) -> Instance:
|
||||
args = [
|
||||
helpers.convert_any_to_type(related_field_type.args[0], set_type),
|
||||
helpers.convert_any_to_type(related_field_type.args[1], get_type),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
from mypy.checker import TypeChecker, fill_typevars
|
||||
from mypy.checker import TypeChecker
|
||||
from mypy.nodes import (
|
||||
GDEF,
|
||||
CallExpr,
|
||||
@@ -19,6 +19,7 @@ from mypy.plugin import AttributeContext, DynamicClassDefContext, SemanticAnalyz
|
||||
from mypy.types import AnyType, CallableType, Instance, ProperType
|
||||
from mypy.types import Type as MypyType
|
||||
from mypy.types import TypeOfAny
|
||||
from mypy.typevars import fill_typevars
|
||||
from typing_extensions import Final
|
||||
|
||||
from mypy_django_plugin.lib import fullnames, helpers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Dict, List, Optional, Type, Union, cast
|
||||
from typing import Any, Dict, List, Optional, Type, Union, cast
|
||||
|
||||
from django.db.models import Manager, Model
|
||||
from django.db.models.fields import DateField, DateTimeField, Field
|
||||
@@ -166,7 +166,7 @@ class ModelClassInitializer:
|
||||
|
||||
return queryset_info
|
||||
|
||||
def run_with_model_cls(self, model_cls):
|
||||
def run_with_model_cls(self, model_cls: Type[Model]) -> None:
|
||||
raise NotImplementedError("Implement this in subclasses")
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ class AddDefaultPrimaryKey(ModelClassInitializer):
|
||||
|
||||
def create_autofield(
|
||||
self,
|
||||
auto_field: Field,
|
||||
auto_field: "Field[Any, Any]",
|
||||
dest_name: str,
|
||||
existing_field: bool,
|
||||
) -> None:
|
||||
@@ -394,7 +394,7 @@ class AddManagers(ModelClassInitializer):
|
||||
|
||||
return None
|
||||
|
||||
def get_dynamic_manager(self, fullname: str, manager: Manager) -> Optional[TypeInfo]:
|
||||
def get_dynamic_manager(self, fullname: str, manager: "Manager[Any]") -> Optional[TypeInfo]:
|
||||
"""
|
||||
Try to get a dynamically defined manager
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user