Skip to content

mypy: Fix errors after django*-stubs upgrade

Since the release of django-stubs v1.11.0 and djangorestframework-stubs v1.6.0, the following mypy errors were raised:

[2022-05-31T14:11:53.618Z] mypy run-test-pre: PYTHONHASHSEED='808326189'

[2022-05-31T14:11:53.618Z] mypy run-test: commands[0] | mypy swh

[2022-05-31T14:12:05.715Z] swh/web/common/utils.py:104: error: Incompatible types in assignment (expression has type "Union[Any, str, List[object]]", target has type "Union[str, bytes]")

[2022-05-31T14:12:05.716Z] swh/web/common/identifiers.py:118: error: Incompatible types in assignment (expression has type "Union[Any, str, List[object]]", target has type "Union[str, bytes]")

[2022-05-31T14:12:05.716Z] swh/web/common/identifiers.py:153: error: Incompatible types in assignment (expression has type "Union[str, List[object]]", target has type "Union[str, bytes]")

[2022-05-31T14:12:05.716Z] swh/web/common/identifiers.py:157: error: Item "List[object]" of "Union[str, List[object]]" has no attribute "endswith"

[2022-05-31T14:12:05.716Z] swh/web/common/identifiers.py:158: error: Incompatible types in assignment (expression has type "Union[str, List[object]]", target has type "Union[str, bytes]")

[2022-05-31T14:12:05.716Z] swh/web/common/identifiers.py:160: error: Incompatible types in assignment (expression has type "Union[str, List[object]]", target has type "Union[str, bytes]")

[2022-05-31T14:12:06.627Z] swh/web/tests/utils.py:61: error: Argument "response" to "_assert_http_response" has incompatible type "_MonkeyPatchedWSGIResponse"; expected "HttpResponse"

[2022-05-31T14:12:06.627Z] swh/web/tests/utils.py:95: error: Argument "response" to "_assert_http_response" has incompatible type "_MonkeyPatchedWSGIResponse"; expected "HttpResponse"

[2022-05-31T14:12:06.627Z] swh/web/tests/conftest.py:24: error: Unused "type: ignore" comment

[2022-05-31T14:12:06.877Z] Found 9 errors in 4 files (checked 217 source files)

Migrated from D7938 (view on Phabricator)

Merge request reports