From 4f6d48fe45606473bb1288b088857656d8122f35 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 13 Aug 2022 17:17:51 +0000 Subject: [PATCH] Fix latest flake completely broken, fix latest typing issues. --- bemani/frontend/app.py | 2 +- bemani/frontend/base.py | 7 ++++--- bemani/frontend/bishi/bishi.py | 2 +- bemani/frontend/ddr/cache.py | 2 +- bemani/frontend/iidx/cache.py | 2 +- bemani/frontend/iidx/iidx.py | 2 +- bemani/frontend/jubeat/cache.py | 2 +- bemani/frontend/mga/mga.py | 2 +- bemani/frontend/museca/cache.py | 2 +- bemani/frontend/museca/museca.py | 2 +- bemani/frontend/popn/cache.py | 2 +- bemani/frontend/reflec/cache.py | 2 +- bemani/frontend/reflec/reflec.py | 2 +- bemani/frontend/sdvx/cache.py | 2 +- bemani/frontend/sdvx/sdvx.py | 2 +- bemani/frontend/types.py | 2 +- requirements.txt | 2 +- 17 files changed, 20 insertions(+), 19 deletions(-) diff --git a/bemani/frontend/app.py b/bemani/frontend/app.py index b76240c..51948ac 100644 --- a/bemani/frontend/app.py +++ b/bemani/frontend/app.py @@ -4,7 +4,7 @@ import traceback from typing import Callable, Dict, Any, Optional, List from react.jsx import JSXTransformer # type: ignore from flask import Flask, flash, request, redirect, Response, url_for, render_template, got_request_exception, jsonify as flask_jsonify -from flask_caching import Cache # type: ignore +from flask_caching import Cache from functools import wraps from bemani.common import AESCipher, GameConstants diff --git a/bemani/frontend/base.py b/bemani/frontend/base.py index f14dfe6..714bbef 100644 --- a/bemani/frontend/base.py +++ b/bemani/frontend/base.py @@ -1,9 +1,9 @@ # vim: set fileencoding=utf-8 import copy from abc import ABC -from typing import Any, Dict, Iterator, List, Optional, Set, Tuple +from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, cast -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.common import GameConstants, Profile, ValidatedDict, ID from bemani.data import Data, Config, Score, Attempt, Link, Song, UserID, RemoteUser @@ -108,7 +108,8 @@ class FrontendBase(ABC): if not force_db_load: cached_songs = self.cache.get(f'{self.game.value}.sorted_songs') if cached_songs is not None: - return cached_songs + # Not sure why mypy insists that this is a str instead of Any. + return cast(Dict[int, Dict[str, Any]], cached_songs) # Find all songs in the game, process notecounts and difficulties songs: Dict[int, Dict[str, Any]] = {} diff --git a/bemani/frontend/bishi/bishi.py b/bemani/frontend/bishi/bishi.py index 0ac0a3f..680d3b8 100644 --- a/bemani/frontend/bishi/bishi.py +++ b/bemani/frontend/bishi/bishi.py @@ -2,7 +2,7 @@ import copy from typing import Any, Dict, Iterator, Tuple -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.bishi import BishiBashiFactory from bemani.common import Profile, ValidatedDict, ID, GameConstants diff --git a/bemani/frontend/ddr/cache.py b/bemani/frontend/ddr/cache.py index e2de49c..486cb0c 100644 --- a/bemani/frontend/ddr/cache.py +++ b/bemani/frontend/ddr/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/iidx/cache.py b/bemani/frontend/iidx/cache.py index 0e157d4..32c2156 100644 --- a/bemani/frontend/iidx/cache.py +++ b/bemani/frontend/iidx/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/iidx/iidx.py b/bemani/frontend/iidx/iidx.py index 4589dfa..20cf137 100644 --- a/bemani/frontend/iidx/iidx.py +++ b/bemani/frontend/iidx/iidx.py @@ -1,7 +1,7 @@ # vim: set fileencoding=utf-8 from typing import Any, Dict, Iterator, Optional, Tuple, List -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.iidx import IIDXFactory, IIDXBase from bemani.common import Profile, ValidatedDict, GameConstants, RegionConstants diff --git a/bemani/frontend/jubeat/cache.py b/bemani/frontend/jubeat/cache.py index daa966f..8236fed 100644 --- a/bemani/frontend/jubeat/cache.py +++ b/bemani/frontend/jubeat/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/mga/mga.py b/bemani/frontend/mga/mga.py index d3c5283..202a7cb 100644 --- a/bemani/frontend/mga/mga.py +++ b/bemani/frontend/mga/mga.py @@ -2,7 +2,7 @@ import copy from typing import Any, Dict, Iterator, Tuple -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.mga import MetalGearArcadeFactory from bemani.common import Profile, ValidatedDict, ID, GameConstants diff --git a/bemani/frontend/museca/cache.py b/bemani/frontend/museca/cache.py index 48c217a..633133e 100644 --- a/bemani/frontend/museca/cache.py +++ b/bemani/frontend/museca/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/museca/museca.py b/bemani/frontend/museca/museca.py index 355c88c..08cf465 100644 --- a/bemani/frontend/museca/museca.py +++ b/bemani/frontend/museca/museca.py @@ -1,7 +1,7 @@ # vim: set fileencoding=utf-8 from typing import Any, Dict, Iterator, List, Tuple -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.museca import MusecaFactory, MusecaBase from bemani.common import GameConstants, VersionConstants, DBConstants, Profile, ValidatedDict diff --git a/bemani/frontend/popn/cache.py b/bemani/frontend/popn/cache.py index 2df1d5f..e849f5f 100644 --- a/bemani/frontend/popn/cache.py +++ b/bemani/frontend/popn/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/reflec/cache.py b/bemani/frontend/reflec/cache.py index a57d5f9..7807fd8 100644 --- a/bemani/frontend/reflec/cache.py +++ b/bemani/frontend/reflec/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/reflec/reflec.py b/bemani/frontend/reflec/reflec.py index 5ca0586..ab978a5 100644 --- a/bemani/frontend/reflec/reflec.py +++ b/bemani/frontend/reflec/reflec.py @@ -1,7 +1,7 @@ # vim: set fileencoding=utf-8 from typing import Any, Dict, Iterator, List, Tuple -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.reflec import ReflecBeatFactory, ReflecBeatBase from bemani.common import GameConstants, Profile, ValidatedDict diff --git a/bemani/frontend/sdvx/cache.py b/bemani/frontend/sdvx/cache.py index d6d4c2f..f93df91 100644 --- a/bemani/frontend/sdvx/cache.py +++ b/bemani/frontend/sdvx/cache.py @@ -1,4 +1,4 @@ -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.data import Config, Data from bemani.frontend.app import app diff --git a/bemani/frontend/sdvx/sdvx.py b/bemani/frontend/sdvx/sdvx.py index 26d6252..087875c 100644 --- a/bemani/frontend/sdvx/sdvx.py +++ b/bemani/frontend/sdvx/sdvx.py @@ -1,7 +1,7 @@ # vim: set fileencoding=utf-8 from typing import Any, Dict, Iterator, List, Tuple -from flask_caching import Cache # type: ignore +from flask_caching import Cache from bemani.backend.sdvx import SoundVoltexFactory, SoundVoltexBase from bemani.common import GameConstants, Profile, ValidatedDict diff --git a/bemani/frontend/types.py b/bemani/frontend/types.py index 89f5fdf..667eae8 100644 --- a/bemani/frontend/types.py +++ b/bemani/frontend/types.py @@ -3,7 +3,7 @@ from typing import Optional, TYPE_CHECKING if TYPE_CHECKING: from flask.ctx import _AppCtxGlobals - from flask_caching import Cache # type: ignore + from flask_caching import Cache from bemani.data import Config, Data, UserID diff --git a/requirements.txt b/requirements.txt index 2b9cbe1..2f1b5f3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ types-Werkzeug types-Flask types-freezegun types-python-dateutil -flake8 +flake8==4.0.1 typed-ast freezegun pyreact