Skip to content

Commit 9874789

Browse files
authoredJan 24, 2023
Update to mypy 0.991 for compatible-mypy & CI (typeddjango#1260)
Made a few tweaks that were needed to get our CI passing with mypy 0.991.
1 parent d716b49 commit 9874789

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed
 

‎mypy.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ ignore_missing_imports = True
77
incremental = True
88
strict_optional = True
99
show_traceback = True
10-
warn_no_return = False
1110
warn_unused_ignores = True
1211
warn_redundant_casts = True
1312
warn_unused_configs = True
1413
warn_unreachable = True
1514
disallow_untyped_defs = true
1615
disallow_incomplete_defs = true
16+
show_error_codes = False
17+
disable_error_code = empty-body
1718

1819
plugins =
1920
mypy_django_plugin.main

‎mypy_django_plugin/main.py

+4
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ def get_customize_class_mro_hook(self, fullname: str) -> Optional[Callable[[Clas
249249
and sym.node.has_base(fullnames.BASE_MANAGER_CLASS_FULLNAME)
250250
):
251251
return reparametrize_any_manager_hook
252+
else:
253+
return None
252254

253255
def get_base_class_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]:
254256
# Base class is a Model class definition
@@ -309,6 +311,8 @@ def get_type_analyze_hook(self, fullname: str) -> Optional[Callable[[AnalyzeType
309311
"django_stubs_ext.annotations.WithAnnotations",
310312
):
311313
return partial(handle_annotated_type, django_context=self.django_context)
314+
else:
315+
return None
312316

313317
def get_dynamic_class_hook(self, fullname: str) -> Optional[Callable[[DynamicClassDefContext], None]]:
314318
# Create a new manager class definition when a manager's '.from_queryset' classmethod is called

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ psycopg2-binary
99
-e .[compatible-mypy]
1010

1111
# Overrides:
12-
mypy==0.982
12+
mypy==0.991

‎scripts/enabled_test_modules.py

+8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
'error: "HttpResponse" has no attribute "streaming_content"',
114114
'error: "HttpResponse" has no attribute "context_data"',
115115
'Duplicate module named "apps"',
116+
"Function is missing a return type annotation",
117+
"Function is missing a type annotation",
118+
"Library stubs not installed for ",
116119
],
117120
"admin_checks": ['Argument 1 to "append" of "list" has incompatible type "str"; expected "CheckMessage"'],
118121
"admin_default_site": [
@@ -512,6 +515,11 @@
512515
"wsgi": [
513516
'"HttpResponse" has no attribute "block_size"',
514517
],
518+
# test_runner_apps/tagged/tests_syntax_error.py
519+
"test_runner_apps": [
520+
"invalid syntax",
521+
"invalid decimal literal",
522+
],
515523
}
516524

517525

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def find_stub_files(name: str) -> List[str]:
3131
]
3232

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

3737
setup(

‎tests/typecheck/contrib/admin/test_options.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
from django.contrib import admin
108108
109109
class A(admin.ModelAdmin):
110-
fieldsets = [ # type: ignore
110+
fieldsets = [
111111
(None, {}), # E: Missing key "fields" for TypedDict "_FieldOpts"
112112
]
113113
- case: errors_on_invalid_radio_fields

0 commit comments

Comments
 (0)
Please sign in to comment.