From 0c7980fa3adcbbd50180904a70e66281755d2c89 Mon Sep 17 00:00:00 2001
From: Sayantan <sayantan.sayanaldo@gmail.com>
Date: Wed, 19 Jan 2022 13:55:40 +0530
Subject: [PATCH 1/4] fixed mypy failing errors

---
 ignite/contrib/handlers/neptune_logger.py | 1 +
 ignite/contrib/handlers/visdom_logger.py  | 1 +
 ignite/contrib/handlers/wandb_logger.py   | 1 +
 ignite/engine/deterministic.py            | 1 +
 ignite/handlers/checkpoint.py             | 1 +
 ignite/handlers/param_scheduler.py        | 1 +
 ignite/handlers/time_profilers.py         | 2 +-
 tests/run_code_style.sh                   | 2 +-
 8 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ignite/contrib/handlers/neptune_logger.py b/ignite/contrib/handlers/neptune_logger.py
index 1dd4c41795c3..484b53276ba1 100644
--- a/ignite/contrib/handlers/neptune_logger.py
+++ b/ignite/contrib/handlers/neptune_logger.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 """Neptune logger and its helper handlers."""
 import tempfile
 from typing import Any, Callable, List, Mapping, Optional, Union
diff --git a/ignite/contrib/handlers/visdom_logger.py b/ignite/contrib/handlers/visdom_logger.py
index b5e2b4337f65..260ce6aa4af3 100644
--- a/ignite/contrib/handlers/visdom_logger.py
+++ b/ignite/contrib/handlers/visdom_logger.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 """Visdom logger and its helper handlers."""
 import os
 from typing import Any, Callable, Dict, List, Optional, Union, cast
diff --git a/ignite/contrib/handlers/wandb_logger.py b/ignite/contrib/handlers/wandb_logger.py
index ffe677b3cf99..bf498159d8f2 100644
--- a/ignite/contrib/handlers/wandb_logger.py
+++ b/ignite/contrib/handlers/wandb_logger.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 """WandB logger and its helper handlers."""
 from typing import Any, Callable, List, Optional, Union
 
diff --git a/ignite/engine/deterministic.py b/ignite/engine/deterministic.py
index b82e68fef0d3..83efee9afcbd 100644
--- a/ignite/engine/deterministic.py
+++ b/ignite/engine/deterministic.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 import random
 import warnings
 from collections import OrderedDict
diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index 9a366c4f6ec5..d6f37fb7ae45 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 import collections.abc as collections
 import numbers
 import os
diff --git a/ignite/handlers/param_scheduler.py b/ignite/handlers/param_scheduler.py
index 460a28357af3..1957f5215b11 100644
--- a/ignite/handlers/param_scheduler.py
+++ b/ignite/handlers/param_scheduler.py
@@ -1,3 +1,4 @@
+# mypy: no-warn-unused-ignores
 import itertools
 import math
 import numbers
diff --git a/ignite/handlers/time_profilers.py b/ignite/handlers/time_profilers.py
index be0d8c6e8840..abe2e0b732bb 100644
--- a/ignite/handlers/time_profilers.py
+++ b/ignite/handlers/time_profilers.py
@@ -585,7 +585,7 @@ def attach(self, engine: Engine) -> None:
         if not engine.has_event_handler(self._as_first_started):
             engine._event_handlers[Events.STARTED].insert(0, (self._as_first_started, (engine,), {}))
 
-    def get_results(self) -> List[List[Union[str, float]]]:
+    def get_results(self) -> List[List[Union[str, float, Tuple[Union[str, float], Union[str, float]]]]]:
         """
         Method to fetch the aggregated profiler results after the engine is run
 
diff --git a/tests/run_code_style.sh b/tests/run_code_style.sh
index 4e0ec75beb4b..beadb887ddd1 100755
--- a/tests/run_code_style.sh
+++ b/tests/run_code_style.sh
@@ -12,5 +12,5 @@ elif [ $1 = "fmt" ]; then
 elif [ $1 = "mypy" ]; then
     mypy --config-file mypy.ini
 elif [ $1 = "install" ]; then
-    pip install flake8 "black==21.12b0" "isort==5.7.0" "mypy==0.910"
+    pip install flake8 "black==21.12b0" "isort==5.7.0" "mypy"
 fi

From ad46be8ac9a6df9e6df1fac63e258331ef774889 Mon Sep 17 00:00:00 2001
From: Sayantan <sayantan.sayanaldo@gmail.com>
Date: Thu, 20 Jan 2022 15:32:03 +0530
Subject: [PATCH 2/4] fixed errors related to mypy

---
 ignite/contrib/handlers/neptune_logger.py | 3 +--
 ignite/contrib/handlers/visdom_logger.py  | 1 -
 ignite/contrib/handlers/wandb_logger.py   | 1 -
 ignite/engine/deterministic.py            | 5 ++---
 ignite/handlers/checkpoint.py             | 3 +--
 ignite/handlers/param_scheduler.py        | 3 +--
 6 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/ignite/contrib/handlers/neptune_logger.py b/ignite/contrib/handlers/neptune_logger.py
index 484b53276ba1..642b16bb42cf 100644
--- a/ignite/contrib/handlers/neptune_logger.py
+++ b/ignite/contrib/handlers/neptune_logger.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 """Neptune logger and its helper handlers."""
 import tempfile
 from typing import Any, Callable, List, Mapping, Optional, Union
@@ -586,7 +585,7 @@ def __call__(self, checkpoint: Mapping, filename: str, metadata: Optional[Mappin
         with tempfile.NamedTemporaryFile() as tmp:
             # we can not use tmp.name to open tmp.file twice on Win32
             # https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
-            torch.save(checkpoint, tmp.file)  # type: ignore[attr-defined]
+            torch.save(checkpoint, tmp.file)
             self._logger.log_artifact(tmp.name, filename)
 
     @idist.one_rank_only(with_barrier=True)
diff --git a/ignite/contrib/handlers/visdom_logger.py b/ignite/contrib/handlers/visdom_logger.py
index 260ce6aa4af3..b5e2b4337f65 100644
--- a/ignite/contrib/handlers/visdom_logger.py
+++ b/ignite/contrib/handlers/visdom_logger.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 """Visdom logger and its helper handlers."""
 import os
 from typing import Any, Callable, Dict, List, Optional, Union, cast
diff --git a/ignite/contrib/handlers/wandb_logger.py b/ignite/contrib/handlers/wandb_logger.py
index bf498159d8f2..ffe677b3cf99 100644
--- a/ignite/contrib/handlers/wandb_logger.py
+++ b/ignite/contrib/handlers/wandb_logger.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 """WandB logger and its helper handlers."""
 from typing import Any, Callable, List, Optional, Union
 
diff --git a/ignite/engine/deterministic.py b/ignite/engine/deterministic.py
index 83efee9afcbd..86c3512f9240 100644
--- a/ignite/engine/deterministic.py
+++ b/ignite/engine/deterministic.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 import random
 import warnings
 from collections import OrderedDict
@@ -252,12 +251,12 @@ def _from_iteration(self, iteration: int) -> Iterator:
         if isinstance(data, DataLoader):
             try:
                 # following is unsafe for IterableDatasets
-                iteration %= len(data.batch_sampler)  # type: ignore[attr-defined, arg-type]
+                iteration %= len(data.batch_sampler)  # type: ignore[arg-type]
                 # Synchronize dataflow according to state.iteration
                 self._setup_seed()
                 if iteration > 0:
                     # batch sampler is ReproducibleBatchSampler
-                    data.batch_sampler.start_iteration = iteration  # type: ignore[attr-defined, union-attr]
+                    data.batch_sampler.start_iteration = iteration  # type: ignore[union-attr]
                 return iter(data)
             except TypeError as e:
                 # Probably we can do nothing with DataLoader built upon IterableDatasets
diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index d6f37fb7ae45..d4701164c143 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 import collections.abc as collections
 import numbers
 import os
@@ -719,7 +718,7 @@ def _save_func(self, checkpoint: Mapping, path: str, func: Callable, rank: int =
             tmp: Optional[IO[bytes]] = None
             if rank == 0:
                 tmp = tempfile.NamedTemporaryFile(delete=False, dir=self.dirname)
-                tmp_file = tmp.file  # type: ignore
+                tmp_file = tmp.file  
                 tmp_name = tmp.name
             try:
                 func(checkpoint, tmp_file, **self.kwargs)
diff --git a/ignite/handlers/param_scheduler.py b/ignite/handlers/param_scheduler.py
index 1957f5215b11..334acec5fca7 100644
--- a/ignite/handlers/param_scheduler.py
+++ b/ignite/handlers/param_scheduler.py
@@ -1,4 +1,3 @@
-# mypy: no-warn-unused-ignores
 import itertools
 import math
 import numbers
@@ -894,7 +893,7 @@ def simulate_values(  # type: ignore[override]
             torch.save(obj, cache_filepath.as_posix())
 
             values = []
-            scheduler = cls(save_history=False, lr_scheduler=lr_scheduler, **kwargs)  # type: ignore[call-arg]
+            scheduler = cls(save_history=False, lr_scheduler=lr_scheduler, **kwargs)
             for i in range(num_events):
                 params = [p[scheduler.param_name] for p in scheduler.optimizer_param_groups]
                 values.append([i] + params)

From 6f7dc4f2898b0480fe083e0e70a3fe85f8099376 Mon Sep 17 00:00:00 2001
From: Sayantan <sayantan.sayanaldo@gmail.com>
Date: Thu, 20 Jan 2022 18:54:47 +0530
Subject: [PATCH 3/4] removed whitespace that was failing flake tests

---
 ignite/handlers/checkpoint.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index d4701164c143..8d5de48852cd 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -718,7 +718,7 @@ def _save_func(self, checkpoint: Mapping, path: str, func: Callable, rank: int =
             tmp: Optional[IO[bytes]] = None
             if rank == 0:
                 tmp = tempfile.NamedTemporaryFile(delete=False, dir=self.dirname)
-                tmp_file = tmp.file  
+                tmp_file = tmp.file 
                 tmp_name = tmp.name
             try:
                 func(checkpoint, tmp_file, **self.kwargs)

From 3defb8ab7515def898081f81c7bf2614a2999928 Mon Sep 17 00:00:00 2001
From: Sayantan <sayantan.sayanaldo@gmail.com>
Date: Thu, 20 Jan 2022 19:09:57 +0530
Subject: [PATCH 4/4] removed extra whitespace for failing flake test

---
 ignite/handlers/checkpoint.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index 8d5de48852cd..1267a5a2ef8b 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -718,7 +718,7 @@ def _save_func(self, checkpoint: Mapping, path: str, func: Callable, rank: int =
             tmp: Optional[IO[bytes]] = None
             if rank == 0:
                 tmp = tempfile.NamedTemporaryFile(delete=False, dir=self.dirname)
-                tmp_file = tmp.file 
+                tmp_file = tmp.file
                 tmp_name = tmp.name
             try:
                 func(checkpoint, tmp_file, **self.kwargs)