Skip to content

Upgrade to mypy 1.7.0 #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def find_stub_files(name: str) -> List[str]:

# Keep compatible-mypy major.minor version pinned to what we use in CI (requirements.txt)
extras_require = {
"compatible-mypy": ["mypy~=1.6.0", "django-stubs[compatible-mypy]"],
"compatible-mypy": ["mypy~=1.7.0", "django-stubs[compatible-mypy]"],
"coreapi": ["coreapi>=2.0.0"],
"markdown": ["types-Markdown>=0.1.5"],
}
Expand Down
6 changes: 3 additions & 3 deletions tests/typecheck/test_fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

CharField(initial='', default=lambda: '')
CharField(initial=None, default=4) # E: Argument "default" to "CharField" has incompatible type "int"; expected "Union[Union[str, _StrPromise], Callable[[], Union[str, _StrPromise]], None, _Empty]"
CharField(initial={}, default=empty) # E: Argument "initial" to "CharField" has incompatible type "Dict[<nothing>, <nothing>]"; expected "Union[str, Callable[[], str], None, _Empty]"
CharField(initial={}, default=empty) # E: Argument "initial" to "CharField" has incompatible type "Dict[Never, Never]"; expected "Union[str, Callable[[], str], None, _Empty]"

x: Optional[str] = CharField().get_initial()
y: Optional[int] = CharField().get_initial() # E: Incompatible types in assignment (expression has type "Optional[str]", variable has type "Optional[int]")
Expand Down Expand Up @@ -123,13 +123,13 @@
DictField(default={})
DictField(default={'a': 1, 'b': 2})
DictField(default=lambda: {'a': [], 'b': 'str'})
DictField(default=[]) # E: Argument "default" to "DictField" has incompatible type "List[<nothing>]"; expected "Union[Dict[Any, Any], Callable[[], Dict[Any, Any]], None, _Empty]"
DictField(default=[]) # E: Argument "default" to "DictField" has incompatible type "List[Never]"; expected "Union[Dict[Any, Any], Callable[[], Dict[Any, Any]], None, _Empty]"

JSONField(allow_null=True, default=None)
JSONField(default={})
JSONField(default={'a': 1, 'b': 2})
JSONField(default=lambda: {'a': [], 'b': 'str'})
JSONField(default=[]) # E: Argument "default" to "JSONField" has incompatible type "List[<nothing>]"; expected "Union[Mapping[Any, Any], Callable[[], Mapping[Any, Any]], None, _Empty]"
JSONField(default=[]) # E: Argument "default" to "JSONField" has incompatible type "List[Never]"; expected "Union[Mapping[Any, Any], Callable[[], Mapping[Any, Any]], None, _Empty]"

- case: ListField_default
main: |
Expand Down
12 changes: 6 additions & 6 deletions tests/typecheck/test_serializers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
- arg: ""
err: No overload variant of "ReturnList" matches argument type "TestSerializer"
- arg: "[],"
err: No overload variant of "ReturnList" matches argument types "List[<nothing>]", "TestSerializer"
err: No overload variant of "ReturnList" matches argument types "List[Never]", "TestSerializer"
main: |
from rest_framework import serializers
from rest_framework.utils.serializer_helpers import ReturnList
Expand All @@ -125,7 +125,7 @@
- arg: ""
err: All overload variants of "ReturnList" require at least one argument
- arg: "[]"
err: No overload variant of "ReturnList" matches argument type "List[<nothing>]"
err: No overload variant of "ReturnList" matches argument type "List[Never]"
main: |
from rest_framework import serializers
from rest_framework.utils.serializer_helpers import ReturnList
Expand Down Expand Up @@ -176,9 +176,9 @@
- arg: ""
err: No overload variant of "ReturnDict" matches argument type "TestSerializer"
- arg: "{},"
err: No overload variant of "ReturnDict" matches argument types "Dict[<nothing>, <nothing>]", "TestSerializer"
err: No overload variant of "ReturnDict" matches argument types "Dict[Never, Never]", "TestSerializer"
- arg: "[],"
err: No overload variant of "ReturnDict" matches argument types "List[<nothing>]", "TestSerializer"
err: No overload variant of "ReturnDict" matches argument types "List[Never]", "TestSerializer"
- arg: "[('a', 'a')],"
err: No overload variant of "ReturnDict" matches argument types "List[Tuple[str, str]]", "TestSerializer"
main: |
Expand All @@ -205,9 +205,9 @@
- arg: ""
err: All overload variants of "ReturnDict" require at least one argument
- arg: "{}"
err: No overload variant of "ReturnDict" matches argument type "Dict[<nothing>, <nothing>]"
err: No overload variant of "ReturnDict" matches argument type "Dict[Never, Never]"
- arg: "[]"
err: No overload variant of "ReturnDict" matches argument type "List[<nothing>]"
err: No overload variant of "ReturnDict" matches argument type "List[Never]"
- arg: "[('a', 'a')]"
err: No overload variant of "ReturnDict" matches argument type "List[Tuple[str, str]]"
main: |
Expand Down