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

Related to swh/meta#4960
---
 swh/model/cli.py   | 8 ++++++--
 swh/model/model.py | 8 ++------
 tox.ini            | 2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/swh/model/cli.py b/swh/model/cli.py
index 62206619..abcabfe1 100644
--- a/swh/model/cli.py
+++ b/swh/model/cli.py
@@ -69,7 +69,9 @@ def swhid_of_file_content(data) -> CoreSWHID:
     return object.swhid()
 
 
-def model_of_dir(path: bytes, exclude_patterns: Iterable[bytes] = None) -> Directory:
+def model_of_dir(
+    path: bytes, exclude_patterns: Optional[Iterable[bytes]] = None
+) -> Directory:
     from swh.model.from_disk import accept_all_directories, ignore_directories_patterns
 
     dir_filter = (
@@ -81,7 +83,9 @@ def model_of_dir(path: bytes, exclude_patterns: Iterable[bytes] = None) -> Direc
     return Directory.from_disk(path=path, dir_filter=dir_filter)
 
 
-def swhid_of_dir(path: bytes, exclude_patterns: Iterable[bytes] = None) -> CoreSWHID:
+def swhid_of_dir(
+    path: bytes, exclude_patterns: Optional[Iterable[bytes]] = None
+) -> CoreSWHID:
     obj = model_of_dir(path, exclude_patterns)
     return obj.swhid()
 
diff --git a/swh/model/model.py b/swh/model/model.py
index 29c7d6e2..3572284d 100644
--- a/swh/model/model.py
+++ b/swh/model/model.py
@@ -59,10 +59,6 @@ Sha1Git = bytes
 Sha1 = bytes
 
 
-KT = TypeVar("KT")
-VT = TypeVar("VT")
-
-
 def hash_repr(h: bytes) -> str:
     if h is None:
         return "None"
@@ -71,8 +67,8 @@ def hash_repr(h: bytes) -> str:
 
 
 def freeze_optional_dict(
-    d: Union[None, Dict[KT, VT], ImmutableDict[KT, VT]]  # type: ignore
-) -> Optional[ImmutableDict[KT, VT]]:
+    d: Union[None, Dict, ImmutableDict]
+) -> Optional[ImmutableDict]:
     if isinstance(d, dict):
         return ImmutableDict(d)
     else:
diff --git a/tox.ini b/tox.ini
index fc98f013..e042fedd 100644
--- a/tox.ini
+++ b/tox.ini
@@ -43,7 +43,7 @@ commands =
 extras =
   testing
 deps =
-  mypy==0.942
+  mypy==1.0
 commands =
   mypy swh
 
-- 
GitLab