Skip to content

Commit 93fa1d2

Browse files
authored
Update mypy to 0.981 (#1167)
* Update mypy to 0.981 * Fix plugin API * Fix scripts * Fix scripts * Fix plugin
1 parent bba51ce commit 93fa1d2

File tree

11 files changed

+17
-14
lines changed

11 files changed

+17
-14
lines changed

django-stubs/core/management/templates.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TemplateCommand(BaseCommand):
1111
paths_to_remove: Sequence[Any]
1212
verbosity: Any = ...
1313
def add_arguments(self, parser: ArgumentParser) -> None: ...
14-
def handle(self, app_or_project: str, name: str, target: Optional[str] = ..., **options: Any) -> None: ... # type: ignore
14+
def handle(self, app_or_project: str, name: str, target: Optional[str] = ..., **options: Any) -> None: ...
1515
def handle_template(self, template: Optional[str], subdir: Optional[str]) -> str: ...
1616
def validate_name(self, name: str, name_or_dir: str = ...) -> None: ...
1717
def download(self, url: str) -> str: ...

django-stubs/core/servers/basehttp.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ServerHandler(simple_server.ServerHandler):
2020

2121
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
2222
close_connection: bool
23-
connection: WSGIRequest # type: ignore[assignment]
23+
connection: WSGIRequest
2424
request: WSGIRequest
2525
rfile: BytesIO
2626
wfile: BytesIO

django-stubs/db/models/base.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class Model(metaclass=ModelBase):
3636
@classmethod
3737
def add_to_class(cls, name: str, value: Any): ...
3838
@classmethod
39-
def from_db(cls, db: Optional[str], field_names: Collection[str], values: Collection[Any]) -> _Self: ...
39+
def from_db(
40+
cls: Type[_Self], db: Optional[str], field_names: Collection[str], values: Collection[Any]
41+
) -> _Self: ...
4042
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
4143
def full_clean(self, exclude: Optional[Iterable[str]] = ..., validate_unique: bool = ...) -> None: ...
4244
def clean(self) -> None: ...

django-stubs/db/models/query.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
133133
def all(self: _QS) -> _QS: ...
134134
def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
135135
def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
136-
def complex_filter(self, filter_obj: Any) -> _QS: ...
136+
def complex_filter(self: _QS, filter_obj: Any) -> _QS: ...
137137
def count(self) -> int: ...
138138
async def acount(self) -> int: ...
139139
def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ...

django-stubs/utils/feedgenerator.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from typing import Any, Dict, List, Optional, Tuple, Union
3-
from xml.sax import ContentHandler # type: ignore
3+
from xml.sax import ContentHandler
44

55
def rfc2822_date(date: datetime.date) -> str: ...
66
def rfc3339_date(date: datetime.date) -> str: ...

mypy_django_plugin/transformers/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Var,
1717
)
1818
from mypy.plugin import AttributeContext, DynamicClassDefContext, SemanticAnalyzerPluginInterface
19-
from mypy.semanal import has_placeholder
19+
from mypy.semanal_shared import has_placeholder
2020
from mypy.types import AnyType, CallableType, Instance, ProperType
2121
from mypy.types import Type as MypyType
2222
from mypy.types import TypeOfAny

mypy_django_plugin/transformers/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from mypy.semanal import SemanticAnalyzer
1212
from mypy.types import AnyType, Instance
1313
from mypy.types import Type as MypyType
14-
from mypy.types import TypedDictType, TypeOfAny
14+
from mypy.types import TypedDictType, TypeOfAny, get_proper_type
1515
from mypy.typevars import fill_typevars
1616

1717
from mypy_django_plugin.django.context import DjangoContext
@@ -656,11 +656,11 @@ def handle_annotated_type(ctx: AnalyzeTypeContext, django_context: DjangoContext
656656

657657
fields_dict = None
658658
if len(args) > 1:
659-
second_arg_type = ctx.api.analyze_type(args[1])
659+
second_arg_type = get_proper_type(ctx.api.analyze_type(args[1]))
660660
if isinstance(second_arg_type, TypedDictType):
661661
fields_dict = second_arg_type
662662
elif isinstance(second_arg_type, Instance) and second_arg_type.type.fullname == ANNOTATIONS_FULLNAME:
663-
annotations_type_arg = second_arg_type.args[0]
663+
annotations_type_arg = get_proper_type(second_arg_type.args[0])
664664
if isinstance(annotations_type_arg, TypedDictType):
665665
fields_dict = annotations_type_arg
666666
elif not isinstance(annotations_type_arg, AnyType):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ psycopg2-binary
99
-e .[compatible-mypy]
1010

1111
# Overrides:
12-
mypy==0.971
12+
mypy==0.981

scripts/git_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def update(
1717
print(self._cur_line)
1818

1919

20-
def checkout_django_branch(django_version: str, commit_sha: Optional[str]) -> Repo:
20+
def checkout_django_branch(django_version: str, commit_sha: Optional[str]) -> None:
2121
branch = f"stable/{django_version}.x"
2222
if DJANGO_SOURCE_DIRECTORY.exists():
2323
shutil.rmtree(DJANGO_SOURCE_DIRECTORY)

scripts/typecheck_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def is_ignored(line: str, test_folder_name: str, *, ignored_message_freqs: _Dict
6868
django_version = parser.parse_args().django_version
6969
subprocess.check_call([sys.executable, "-m", "pip", "install", f"Django=={django_version}.*"])
7070
commit_sha = DJANGO_COMMIT_REFS[django_version]
71-
repo = checkout_django_branch(django_version, commit_sha)
71+
checkout_django_branch(django_version, commit_sha)
7272
mypy_config_file = (PROJECT_DIRECTORY / "mypy.ini").absolute()
7373
mypy_cache_dir = PROJECT_DIRECTORY / ".mypy_cache"
7474
tests_root = DJANGO_SOURCE_DIRECTORY / "tests"

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def find_stub_files(name: str) -> List[str]:
2020
readme = f.read()
2121

2222
dependencies = [
23-
"mypy>=0.930",
23+
"mypy>=0.980",
2424
"django",
2525
"django-stubs-ext>=0.6.0",
2626
"tomli",
@@ -31,7 +31,7 @@ def find_stub_files(name: str) -> List[str]:
3131
]
3232

3333
extras_require = {
34-
"compatible-mypy": ["mypy>=0.930,<0.980"],
34+
"compatible-mypy": ["mypy>=0.980,<0.990"],
3535
}
3636

3737
setup(
@@ -69,6 +69,7 @@ def find_stub_files(name: str) -> List[str]:
6969
"Framework :: Django :: 3.1",
7070
"Framework :: Django :: 3.2",
7171
"Framework :: Django :: 4.0",
72+
"Framework :: Django :: 4.1",
7273
],
7374
project_urls={
7475
"Release notes": "https://github.com/typeddjango/django-stubs/releases",

0 commit comments

Comments
 (0)