From 50d03102c2d51a066bddb93bb1fef0cf8bf23ca4 Mon Sep 17 00:00:00 2001
From: David Douard <david.douard@sdfa3.org>
Date: Tue, 21 Nov 2023 13:56:00 +0100
Subject: [PATCH] Fix annotations for mypy 1.4 (py37)

---
 swh/model/cli.py         | 10 ++++++----
 swh/model/collections.py |  4 ++--
 tox.ini                  |  2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/swh/model/cli.py b/swh/model/cli.py
index 65086021..7fd99ed0 100644
--- a/swh/model/cli.py
+++ b/swh/model/cli.py
@@ -20,10 +20,12 @@ except ImportError:
     exit(1)
 
 try:
-    from swh.core.cli import swh as swh_cli_group
+    import swh.core.cli
+
+    cli_command = swh.core.cli.swh.command
 except ImportError:
     # stub so that swh-identify can be used when swh-core isn't installed
-    swh_cli_group = click  # type: ignore
+    cli_command = click.command
 
 from swh.model.from_disk import Directory
 from swh.model.swhids import CoreSWHID
@@ -175,7 +177,7 @@ def identify_object(
     return swhid
 
 
-@swh_cli_group.command(context_settings=CONTEXT_SETTINGS)
+@cli_command(context_settings=CONTEXT_SETTINGS)
 @click.option(
     "--dereference/--no-dereference",
     "follow_symlinks",
@@ -304,7 +306,7 @@ def identify(
                 click.echo("SWHID mismatch: %s != %s" % (verify, swhid))
                 sys.exit(1)
         else:
-            for (obj, swhid) in results:
+            for obj, swhid in results:
                 msg = swhid
                 if show_filename:
                     msg = "%s\t%s" % (swhid, os.fsdecode(obj))
diff --git a/swh/model/collections.py b/swh/model/collections.py
index 6de27eed..35314ca0 100644
--- a/swh/model/collections.py
+++ b/swh/model/collections.py
@@ -45,7 +45,7 @@ class ImmutableDict(Mapping, Generic[KT, VT]):
         return self._data[key]
 
     def __iter__(self):
-        for (k, v) in self.data:
+        for k, v in self.data:
             yield k
 
     def __len__(self):
@@ -61,5 +61,5 @@ class ImmutableDict(Mapping, Generic[KT, VT]):
         """Returns a copy of this ImmutableDict without the given key,
         as well as the value associated to the key."""
         new_items = copy.deepcopy(self._data)
-        popped_value = new_items.pop(popped_key, None)
+        popped_value: Optional[VT] = new_items.pop(popped_key, None)
         return (popped_value, ImmutableDict(new_items))
diff --git a/tox.ini b/tox.ini
index 3728a15a..c6ba7d06 100644
--- a/tox.ini
+++ b/tox.ini
@@ -48,7 +48,7 @@ commands =
 extras =
   testing
 deps =
-  mypy==1.0.1
+  mypy>1.4
 commands =
   mypy swh
 
-- 
GitLab