Skip to content

Commit

Permalink
Update to mypy 0.991 for compatible-mypy & CI (#1260)
Browse files Browse the repository at this point in the history
Made a few tweaks that were needed to get our CI passing with mypy 0.991.
  • Loading branch information
intgr committed Jan 24, 2023
1 parent d716b49 commit 9874789
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ ignore_missing_imports = True
incremental = True
strict_optional = True
show_traceback = True
warn_no_return = False
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
disallow_untyped_defs = true
disallow_incomplete_defs = true
show_error_codes = False
disable_error_code = empty-body

plugins =
mypy_django_plugin.main
Expand Down
4 changes: 4 additions & 0 deletions mypy_django_plugin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def get_customize_class_mro_hook(self, fullname: str) -> Optional[Callable[[Clas
and sym.node.has_base(fullnames.BASE_MANAGER_CLASS_FULLNAME)
):
return reparametrize_any_manager_hook
else:
return None

def get_base_class_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]:
# Base class is a Model class definition
Expand Down Expand Up @@ -309,6 +311,8 @@ def get_type_analyze_hook(self, fullname: str) -> Optional[Callable[[AnalyzeType
"django_stubs_ext.annotations.WithAnnotations",
):
return partial(handle_annotated_type, django_context=self.django_context)
else:
return None

def get_dynamic_class_hook(self, fullname: str) -> Optional[Callable[[DynamicClassDefContext], None]]:
# Create a new manager class definition when a manager's '.from_queryset' classmethod is called
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ psycopg2-binary
-e .[compatible-mypy]

# Overrides:
mypy==0.982
mypy==0.991
8 changes: 8 additions & 0 deletions scripts/enabled_test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
'error: "HttpResponse" has no attribute "streaming_content"',
'error: "HttpResponse" has no attribute "context_data"',
'Duplicate module named "apps"',
"Function is missing a return type annotation",
"Function is missing a type annotation",
"Library stubs not installed for ",
],
"admin_checks": ['Argument 1 to "append" of "list" has incompatible type "str"; expected "CheckMessage"'],
"admin_default_site": [
Expand Down Expand Up @@ -512,6 +515,11 @@
"wsgi": [
'"HttpResponse" has no attribute "block_size"',
],
# test_runner_apps/tagged/tests_syntax_error.py
"test_runner_apps": [
"invalid syntax",
"invalid decimal literal",
],
}


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def find_stub_files(name: str) -> List[str]:
]

extras_require = {
"compatible-mypy": ["mypy>=0.980,<0.990"],
"compatible-mypy": ["mypy>=0.991,<1.0"],
}

setup(
Expand Down
2 changes: 1 addition & 1 deletion tests/typecheck/contrib/admin/test_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
from django.contrib import admin
class A(admin.ModelAdmin):
fieldsets = [ # type: ignore
fieldsets = [
(None, {}), # E: Missing key "fields" for TypedDict "_FieldOpts"
]
- case: errors_on_invalid_radio_fields
Expand Down

0 comments on commit 9874789

Please sign in to comment.