mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
Update mypy to 0.981 (#1167)
* Update mypy to 0.981 * Fix plugin API * Fix scripts * Fix scripts * Fix plugin
This commit is contained in:
@@ -11,7 +11,7 @@ class TemplateCommand(BaseCommand):
|
|||||||
paths_to_remove: Sequence[Any]
|
paths_to_remove: Sequence[Any]
|
||||||
verbosity: Any = ...
|
verbosity: Any = ...
|
||||||
def add_arguments(self, parser: ArgumentParser) -> None: ...
|
def add_arguments(self, parser: ArgumentParser) -> None: ...
|
||||||
def handle(self, app_or_project: str, name: str, target: Optional[str] = ..., **options: Any) -> None: ... # type: ignore
|
def handle(self, app_or_project: str, name: str, target: Optional[str] = ..., **options: Any) -> None: ...
|
||||||
def handle_template(self, template: Optional[str], subdir: Optional[str]) -> str: ...
|
def handle_template(self, template: Optional[str], subdir: Optional[str]) -> str: ...
|
||||||
def validate_name(self, name: str, name_or_dir: str = ...) -> None: ...
|
def validate_name(self, name: str, name_or_dir: str = ...) -> None: ...
|
||||||
def download(self, url: str) -> str: ...
|
def download(self, url: str) -> str: ...
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ServerHandler(simple_server.ServerHandler):
|
|||||||
|
|
||||||
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
|
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
|
||||||
close_connection: bool
|
close_connection: bool
|
||||||
connection: WSGIRequest # type: ignore[assignment]
|
connection: WSGIRequest
|
||||||
request: WSGIRequest
|
request: WSGIRequest
|
||||||
rfile: BytesIO
|
rfile: BytesIO
|
||||||
wfile: BytesIO
|
wfile: BytesIO
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ class Model(metaclass=ModelBase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def add_to_class(cls, name: str, value: Any): ...
|
def add_to_class(cls, name: str, value: Any): ...
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_db(cls, db: Optional[str], field_names: Collection[str], values: Collection[Any]) -> _Self: ...
|
def from_db(
|
||||||
|
cls: Type[_Self], db: Optional[str], field_names: Collection[str], values: Collection[Any]
|
||||||
|
) -> _Self: ...
|
||||||
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
||||||
def full_clean(self, exclude: Optional[Iterable[str]] = ..., validate_unique: bool = ...) -> None: ...
|
def full_clean(self, exclude: Optional[Iterable[str]] = ..., validate_unique: bool = ...) -> None: ...
|
||||||
def clean(self) -> None: ...
|
def clean(self) -> None: ...
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
|
|||||||
def all(self: _QS) -> _QS: ...
|
def all(self: _QS) -> _QS: ...
|
||||||
def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
||||||
def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
||||||
def complex_filter(self, filter_obj: Any) -> _QS: ...
|
def complex_filter(self: _QS, filter_obj: Any) -> _QS: ...
|
||||||
def count(self) -> int: ...
|
def count(self) -> int: ...
|
||||||
async def acount(self) -> int: ...
|
async def acount(self) -> int: ...
|
||||||
def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ...
|
def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||||
from xml.sax import ContentHandler # type: ignore
|
from xml.sax import ContentHandler
|
||||||
|
|
||||||
def rfc2822_date(date: datetime.date) -> str: ...
|
def rfc2822_date(date: datetime.date) -> str: ...
|
||||||
def rfc3339_date(date: datetime.date) -> str: ...
|
def rfc3339_date(date: datetime.date) -> str: ...
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from mypy.nodes import (
|
|||||||
Var,
|
Var,
|
||||||
)
|
)
|
||||||
from mypy.plugin import AttributeContext, DynamicClassDefContext, SemanticAnalyzerPluginInterface
|
from mypy.plugin import AttributeContext, DynamicClassDefContext, SemanticAnalyzerPluginInterface
|
||||||
from mypy.semanal import has_placeholder
|
from mypy.semanal_shared import has_placeholder
|
||||||
from mypy.types import AnyType, CallableType, Instance, ProperType
|
from mypy.types import AnyType, CallableType, Instance, ProperType
|
||||||
from mypy.types import Type as MypyType
|
from mypy.types import Type as MypyType
|
||||||
from mypy.types import TypeOfAny
|
from mypy.types import TypeOfAny
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from mypy.plugins import common
|
|||||||
from mypy.semanal import SemanticAnalyzer
|
from mypy.semanal import SemanticAnalyzer
|
||||||
from mypy.types import AnyType, Instance
|
from mypy.types import AnyType, Instance
|
||||||
from mypy.types import Type as MypyType
|
from mypy.types import Type as MypyType
|
||||||
from mypy.types import TypedDictType, TypeOfAny
|
from mypy.types import TypedDictType, TypeOfAny, get_proper_type
|
||||||
from mypy.typevars import fill_typevars
|
from mypy.typevars import fill_typevars
|
||||||
|
|
||||||
from mypy_django_plugin.django.context import DjangoContext
|
from mypy_django_plugin.django.context import DjangoContext
|
||||||
@@ -656,11 +656,11 @@ def handle_annotated_type(ctx: AnalyzeTypeContext, django_context: DjangoContext
|
|||||||
|
|
||||||
fields_dict = None
|
fields_dict = None
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
second_arg_type = ctx.api.analyze_type(args[1])
|
second_arg_type = get_proper_type(ctx.api.analyze_type(args[1]))
|
||||||
if isinstance(second_arg_type, TypedDictType):
|
if isinstance(second_arg_type, TypedDictType):
|
||||||
fields_dict = second_arg_type
|
fields_dict = second_arg_type
|
||||||
elif isinstance(second_arg_type, Instance) and second_arg_type.type.fullname == ANNOTATIONS_FULLNAME:
|
elif isinstance(second_arg_type, Instance) and second_arg_type.type.fullname == ANNOTATIONS_FULLNAME:
|
||||||
annotations_type_arg = second_arg_type.args[0]
|
annotations_type_arg = get_proper_type(second_arg_type.args[0])
|
||||||
if isinstance(annotations_type_arg, TypedDictType):
|
if isinstance(annotations_type_arg, TypedDictType):
|
||||||
fields_dict = annotations_type_arg
|
fields_dict = annotations_type_arg
|
||||||
elif not isinstance(annotations_type_arg, AnyType):
|
elif not isinstance(annotations_type_arg, AnyType):
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ psycopg2-binary
|
|||||||
-e .[compatible-mypy]
|
-e .[compatible-mypy]
|
||||||
|
|
||||||
# Overrides:
|
# Overrides:
|
||||||
mypy==0.971
|
mypy==0.981
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ProgressPrinter(RemoteProgress):
|
|||||||
print(self._cur_line)
|
print(self._cur_line)
|
||||||
|
|
||||||
|
|
||||||
def checkout_django_branch(django_version: str, commit_sha: Optional[str]) -> Repo:
|
def checkout_django_branch(django_version: str, commit_sha: Optional[str]) -> None:
|
||||||
branch = f"stable/{django_version}.x"
|
branch = f"stable/{django_version}.x"
|
||||||
if DJANGO_SOURCE_DIRECTORY.exists():
|
if DJANGO_SOURCE_DIRECTORY.exists():
|
||||||
shutil.rmtree(DJANGO_SOURCE_DIRECTORY)
|
shutil.rmtree(DJANGO_SOURCE_DIRECTORY)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ if __name__ == "__main__":
|
|||||||
django_version = parser.parse_args().django_version
|
django_version = parser.parse_args().django_version
|
||||||
subprocess.check_call([sys.executable, "-m", "pip", "install", f"Django=={django_version}.*"])
|
subprocess.check_call([sys.executable, "-m", "pip", "install", f"Django=={django_version}.*"])
|
||||||
commit_sha = DJANGO_COMMIT_REFS[django_version]
|
commit_sha = DJANGO_COMMIT_REFS[django_version]
|
||||||
repo = checkout_django_branch(django_version, commit_sha)
|
checkout_django_branch(django_version, commit_sha)
|
||||||
mypy_config_file = (PROJECT_DIRECTORY / "mypy.ini").absolute()
|
mypy_config_file = (PROJECT_DIRECTORY / "mypy.ini").absolute()
|
||||||
mypy_cache_dir = PROJECT_DIRECTORY / ".mypy_cache"
|
mypy_cache_dir = PROJECT_DIRECTORY / ".mypy_cache"
|
||||||
tests_root = DJANGO_SOURCE_DIRECTORY / "tests"
|
tests_root = DJANGO_SOURCE_DIRECTORY / "tests"
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -20,7 +20,7 @@ with open("README.md") as f:
|
|||||||
readme = f.read()
|
readme = f.read()
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mypy>=0.930",
|
"mypy>=0.980",
|
||||||
"django",
|
"django",
|
||||||
"django-stubs-ext>=0.6.0",
|
"django-stubs-ext>=0.6.0",
|
||||||
"tomli",
|
"tomli",
|
||||||
@@ -31,7 +31,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
extras_require = {
|
extras_require = {
|
||||||
"compatible-mypy": ["mypy>=0.930,<0.980"],
|
"compatible-mypy": ["mypy>=0.980,<0.990"],
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@@ -69,6 +69,7 @@ setup(
|
|||||||
"Framework :: Django :: 3.1",
|
"Framework :: Django :: 3.1",
|
||||||
"Framework :: Django :: 3.2",
|
"Framework :: Django :: 3.2",
|
||||||
"Framework :: Django :: 4.0",
|
"Framework :: Django :: 4.0",
|
||||||
|
"Framework :: Django :: 4.1",
|
||||||
],
|
],
|
||||||
project_urls={
|
project_urls={
|
||||||
"Release notes": "https://github.com/typeddjango/django-stubs/releases",
|
"Release notes": "https://github.com/typeddjango/django-stubs/releases",
|
||||||
|
|||||||
Reference in New Issue
Block a user