Repository: optuna/optuna

Issue:
Migrate mypy version to 0.910
As of today (Nov. 28th, 2021), the latest version of mypy is 0.910. On the other hand, now Optuna uses 0.790.
I think it is better to migrate to the latest version, but mypy 0.910 emits a lot of errors for the current Optuna codes like the following:

```
optuna/storages/_rdb/alembic/versions/v2.6.0.a_.py:21: error: Function is missing a return type annotation
optuna/storages/_rdb/alembic/versions/v2.6.0.a_.py:21: note: Use "-> None" if function does not return a value
optuna/storages/_rdb/alembic/versions/v2.6.0.a_.py:34: error: Function is missing a return type annotation
optuna/storages/_rdb/alembic/versions/v2.6.0.a_.py:34: note: Use "-> None" if function does not return a value
...
```

Thus we also need to add some fixes.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -50,9 +50,16 @@ def get_tests_require() -> List[str]:
 def get_extras_require() -> Dict[str, List[str]]:
 
     requirements = {
-        # TODO(HideakiImamura) Unpin mypy version after fixing "Duplicate modules" error in
-        # tutorials.
-        "checking": ["black", "hacking", "isort", "mypy==0.790", "blackdoc"],
+        "checking": [
+            "black",
+            "hacking",
+            "isort",
+            "blackdoc",
+            "mypy",
+            "types-setuptools",
+            "types-redis",
+            "types-PyYAML",
+        ],
         "codecov": ["codecov", "pytest-cov"],
         "doctest": [
             "cma",


Test patch:
diff --git a/tests/trial_tests/test_trial.py b/tests/trial_tests/test_trial.py
--- a/tests/trial_tests/test_trial.py
+++ b/tests/trial_tests/test_trial.py
@@ -81,8 +81,7 @@ def test_check_distribution_suggest_uniform(storage_mode: str) -> None:
             trial.suggest_uniform("x", 10, 30)
 
         # we expect exactly one warning (not counting ones caused by deprecation)
-        record = [r for r in record if r.category != FutureWarning]
-        assert len(record) == 1
+        assert len([r for r in record if r.category != FutureWarning]) == 1
 
         with pytest.raises(ValueError):
             trial.suggest_int("x", 10, 20)
@@ -106,8 +105,7 @@ def test_check_distribution_suggest_loguniform(storage_mode: str) -> None:
             trial.suggest_loguniform("x", 10, 30)
 
         # we expect exactly one warning (not counting ones caused by deprecation)
-        record = [r for r in record if r.category != FutureWarning]
-        assert len(record) == 1
+        assert len([r for r in record if r.category != FutureWarning]) == 1
 
         with pytest.raises(ValueError):
             trial.suggest_int("x", 10, 20)
@@ -131,8 +129,7 @@ def test_check_distribution_suggest_discrete_uniform(storage_mode: str) -> None:
             trial.suggest_discrete_uniform("x", 10, 22, 2)
 
         # we expect exactly one warning (not counting ones caused by deprecation)
-        record = [r for r in record if r.category != FutureWarning]
-        assert len(record) == 1
+        assert len([r for r in record if r.category != FutureWarning]) == 1
 
         with pytest.raises(ValueError):
             trial.suggest_int("x", 10, 20, 2)