Skip to content

Commit 0aa7bf1

Browse files
authored
Update recommended mypy & CI to 1.1.1, update MultiValueDict (#1391)
* Updated mypy to 1.1.1 for compatible-mypy and CI * Fixes MultiValueDict.setdefault() compatibility with MutableMapping from newer typeshed * Error messages in test_items_custom_model were reordered
1 parent a63bcbe commit 0aa7bf1

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

django-stubs/utils/datastructures.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class MultiValueDict(dict[_K, _V]):
6565
def get(self, key: _K, default: _Z = ...) -> _V | _Z: ...
6666
def getlist(self, key: _K, default: _Z = ...) -> list[_V] | _Z: ...
6767
def setlist(self, key: _K, list_: list[_V]) -> None: ...
68-
def setdefault(self, key: _K, default: _V = ...) -> _V: ...
68+
@overload
69+
def setdefault(self: MultiValueDict[_K, _V | None], key: _K, default: None = ...) -> _V | None: ...
70+
@overload
71+
def setdefault(self, key: _K, default: _V) -> _V: ...
6972
def setlistdefault(self, key: _K, default_list: list[_V] | None = ...) -> list[_V]: ...
7073
def appendlist(self, key: _K, value: _V) -> None: ...
7174
def items(self) -> Iterator[tuple[_K, _V | list[object]]]: ... # type: ignore

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==1.0.1
12+
mypy==1.1.1

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>=1.0,<1.1"],
34+
"compatible-mypy": ["mypy>=1.1.1,<1.2"],
3535
}
3636

3737
setup(

tests/typecheck/contrib/sitemaps/test_generic_sitemap.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
]
4646
out: |
4747
main:24: error: Return type "str" of "items" incompatible with return type "Iterable[Offer]" in supertype "Sitemap"
48+
main:26: error: Return type "int" of "location" incompatible with return type "str" in supertype "Sitemap"
4849
main:26: error: Argument 1 of "location" is incompatible with supertype "Sitemap"; supertype defines the argument type as "Offer"
4950
main:26: note: This violates the Liskov substitution principle
5051
main:26: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
51-
main:26: error: Return type "int" of "location" incompatible with return type "str" in supertype "Sitemap"
5252
main:40: error: Argument 1 to "GenericSitemap" has incompatible type "Dict[str, List[int]]"; expected "Mapping[str, Union[datetime, _QuerySet[Offer, Offer], str]]"
5353
5454
installed_apps:

0 commit comments

Comments
 (0)