From 68d277411c06617fc22e18a89348b0dc3475d654 Mon Sep 17 00:00:00 2001
From: Antoine Lambert <anlambert@softwareheritage.org>
Date: Fri, 17 Feb 2023 14:23:26 +0100
Subject: [PATCH] mypy: Bump to 1.0 and fix new typing errors

Related to swh/meta#4960
---
 swh/core/collections.py      | 2 +-
 swh/core/db/tests/test_db.py | 9 ++-------
 tox.ini                      | 2 +-
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/swh/core/collections.py b/swh/core/collections.py
index ed7b8692..512e2846 100644
--- a/swh/core/collections.py
+++ b/swh/core/collections.py
@@ -19,7 +19,7 @@ class SortedList(Generic[SortedListKey, SortedListItem]):
 
     def __init__(
         self,
-        data: List[SortedListItem] = None,
+        data: List[SortedListItem] = [],
         key: Optional[Callable[[SortedListItem], SortedListKey]] = None,
     ):
         if key is None:
diff --git a/swh/core/db/tests/test_db.py b/swh/core/db/tests/test_db.py
index 2d127079..c0779436 100644
--- a/swh/core/db/tests/test_db.py
+++ b/swh/core/db/tests/test_db.py
@@ -8,7 +8,7 @@ import datetime
 from enum import IntEnum
 import inspect
 from string import printable
-from typing import Any
+from typing import Any, Callable
 from unittest.mock import MagicMock, Mock
 import uuid
 
@@ -17,17 +17,12 @@ from hypothesis.extra.pytz import timezones
 import psycopg2
 import pytest
 from pytest_postgresql import factories
-from typing_extensions import Protocol
 
 from swh.core.db import BaseDb
 from swh.core.db.common import db_transaction, db_transaction_generator
 from swh.core.db.tests.conftest import function_scoped_fixture_check
 
-
-# workaround mypy bug https://github.com/python/mypy/issues/5485
-class Converter(Protocol):
-    def __call__(self, x: Any) -> Any:
-        ...
+Converter = Callable[[Any], Any]
 
 
 @dataclass
diff --git a/tox.ini b/tox.ini
index 49c71648..a22f00c2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -50,7 +50,7 @@ extras =
   http
   github
 deps =
-  mypy==0.942
+  mypy==1.0
 commands =
   mypy swh
 
-- 
GitLab