Fix some new typing errors (a bunch of ignores can be removed!), black errors.
This commit is contained in:
parent
223c93874c
commit
f63247b605
@ -177,7 +177,7 @@ class JubeatBase(CoreHandler, CardManagerHandler, PASELIHandler, Base):
|
||||
else:
|
||||
# We will want to fetch the remaining scores that were in our
|
||||
# cache.
|
||||
scores = self.cache.get(cache_key) # type: ignore
|
||||
scores = self.cache.get(cache_key)
|
||||
|
||||
if len(scores) < 50:
|
||||
# We simply return the whole amount for this, and cache nothing.
|
||||
|
@ -529,11 +529,15 @@ class JubeatFesto(
|
||||
(90000037 if dataver < 2021081600 else 90000172, 0),
|
||||
],
|
||||
[
|
||||
(
|
||||
(
|
||||
80000034
|
||||
if dataver < 2020062900
|
||||
else (
|
||||
30000108 if dataver < 2020091300 else (40000107 if dataver < 2021020100 else 30000004)
|
||||
30000108
|
||||
if dataver < 2020091300
|
||||
else (40000107 if dataver < 2021020100 else 30000004)
|
||||
)
|
||||
),
|
||||
0,
|
||||
),
|
||||
|
@ -335,12 +335,12 @@ class GlobalMusicData(BaseGlobalData):
|
||||
{
|
||||
"rank": self.__max(oldscore.data["rank"], newscore.data["rank"]),
|
||||
"halo": self.__max(oldscore.data["halo"], newscore.data["halo"]),
|
||||
"ghost": oldscore.data.get("ghost")
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get("ghost"),
|
||||
"trace": oldscore.data.get("trace")
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get("trace"),
|
||||
"ghost": (
|
||||
oldscore.data.get("ghost") if oldscore.points > newscore.points else newscore.data.get("ghost")
|
||||
),
|
||||
"trace": (
|
||||
oldscore.data.get("trace") if oldscore.points > newscore.points else newscore.data.get("trace")
|
||||
),
|
||||
"combo": self.__max(oldscore.data["combo"], newscore.data["combo"]),
|
||||
},
|
||||
)
|
||||
@ -360,19 +360,23 @@ class GlobalMusicData(BaseGlobalData):
|
||||
oldscore.plays + newscore.plays,
|
||||
{
|
||||
"clear_status": self.__max(oldscore.data["clear_status"], newscore.data["clear_status"]),
|
||||
"ghost": oldscore.data.get("ghost")
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get("ghost"),
|
||||
"ghost": (
|
||||
oldscore.data.get("ghost") if oldscore.points > newscore.points else newscore.data.get("ghost")
|
||||
),
|
||||
"miss_count": self.__min(
|
||||
oldscore.data.get_int("miss_count", -1),
|
||||
newscore.data.get_int("miss_count", -1),
|
||||
),
|
||||
"pgreats": oldscore.data.get_int("pgreats", -1)
|
||||
"pgreats": (
|
||||
oldscore.data.get_int("pgreats", -1)
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get_int("pgreats", -1),
|
||||
"greats": oldscore.data.get_int("greats", -1)
|
||||
else newscore.data.get_int("pgreats", -1)
|
||||
),
|
||||
"greats": (
|
||||
oldscore.data.get_int("greats", -1)
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get_int("greats", -1),
|
||||
else newscore.data.get_int("greats", -1)
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
@ -392,9 +396,9 @@ class GlobalMusicData(BaseGlobalData):
|
||||
oldscore.location, # Always propagate location from local setup if possible
|
||||
oldscore.plays + newscore.plays,
|
||||
{
|
||||
"ghost": oldscore.data.get("ghost")
|
||||
if oldscore.points > newscore.points
|
||||
else newscore.data.get("ghost"),
|
||||
"ghost": (
|
||||
oldscore.data.get("ghost") if oldscore.points > newscore.points else newscore.data.get("ghost")
|
||||
),
|
||||
"combo": self.__max(oldscore.data["combo"], newscore.data["combo"]),
|
||||
"medal": self.__max(oldscore.data["medal"], newscore.data["medal"]),
|
||||
# Conditionally include this if we have any info for it.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import copy
|
||||
import os
|
||||
from sqlalchemy.engine import Engine # type: ignore
|
||||
from sqlalchemy.engine import Engine
|
||||
from typing import Any, Dict, Optional, Set
|
||||
|
||||
from bemani.common import GameConstants, RegionConstants
|
||||
|
@ -2,13 +2,13 @@ import os
|
||||
|
||||
import alembic.config
|
||||
from alembic.migration import MigrationContext
|
||||
from alembic.autogenerate import compare_metadata # type: ignore
|
||||
from sqlalchemy import create_engine # type: ignore
|
||||
from sqlalchemy.orm import scoped_session # type: ignore
|
||||
from alembic.autogenerate import compare_metadata
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.engine import Engine # type: ignore
|
||||
from sqlalchemy.sql import text # type: ignore
|
||||
from sqlalchemy.exc import ProgrammingError # type: ignore
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.sql import text
|
||||
from sqlalchemy.exc import ProgrammingError
|
||||
|
||||
from bemani.data.api.user import GlobalUserData
|
||||
from bemani.data.api.game import GlobalGameData
|
||||
@ -153,7 +153,7 @@ class Data:
|
||||
]
|
||||
alembicArgs.extend(args)
|
||||
os.chdir(base_dir)
|
||||
alembic.config.main(argv=alembicArgs) # type: ignore
|
||||
alembic.config.main(argv=alembicArgs)
|
||||
|
||||
def create(self) -> None:
|
||||
"""
|
||||
|
@ -1,6 +1,6 @@
|
||||
import uuid
|
||||
from sqlalchemy import Table, Column # type: ignore
|
||||
from sqlalchemy.types import String, Integer # type: ignore
|
||||
from sqlalchemy import Table, Column
|
||||
from sqlalchemy.types import String, Integer
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from bemani.common import Time
|
||||
|
@ -6,11 +6,11 @@ from typing_extensions import Final
|
||||
from bemani.common import Time
|
||||
from bemani.data.config import Config
|
||||
|
||||
from sqlalchemy.engine.base import Connection # type: ignore
|
||||
from sqlalchemy.engine import CursorResult # type: ignore
|
||||
from sqlalchemy.sql import text # type: ignore
|
||||
from sqlalchemy.types import String, Integer # type: ignore
|
||||
from sqlalchemy import Table, Column, MetaData # type: ignore
|
||||
from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.sql import text
|
||||
from sqlalchemy.types import String, Integer
|
||||
from sqlalchemy import Table, Column, MetaData
|
||||
|
||||
metadata = MetaData()
|
||||
|
||||
@ -40,7 +40,7 @@ class _BytesEncoder(json.JSONEncoder):
|
||||
class BaseData:
|
||||
SESSION_LENGTH: Final[int] = 32
|
||||
|
||||
def __init__(self, config: Config, conn: Connection) -> None:
|
||||
def __init__(self, config: Config, conn: scoped_session) -> None:
|
||||
"""
|
||||
Initialize any DB singleton.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.types import String, Integer, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import String, Integer, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from bemani.common import GameConstants, ValidatedDict, Time
|
||||
|
@ -1,8 +1,8 @@
|
||||
import copy
|
||||
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.types import String, Integer, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import String, Integer, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
|
||||
from bemani.common import GameConstants, ValidatedDict, Time
|
||||
|
@ -1,6 +1,6 @@
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.types import String, Integer, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import String, Integer, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
from typing_extensions import Final
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.exc import IntegrityError # type: ignore
|
||||
from sqlalchemy.types import String, Integer, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.types import String, Integer, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
|
||||
from bemani.common import GameConstants, Time
|
||||
|
@ -1,6 +1,6 @@
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.types import String, Integer, Text, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import String, Integer, Text, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
|
||||
from bemani.common import GameConstants, Time
|
||||
|
@ -1,8 +1,8 @@
|
||||
import random
|
||||
from sqlalchemy import Table, Column, UniqueConstraint # type: ignore
|
||||
from sqlalchemy.types import String, Integer, JSON # type: ignore
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger # type: ignore
|
||||
from sqlalchemy.exc import IntegrityError # type: ignore
|
||||
from sqlalchemy import Table, Column, UniqueConstraint
|
||||
from sqlalchemy.types import String, Integer, JSON
|
||||
from sqlalchemy.dialects.mysql import BIGINT as BigInteger
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
from typing_extensions import Final
|
||||
from passlib.hash import pbkdf2_sha512 # type: ignore
|
||||
|
@ -377,12 +377,14 @@ class AP2PlaceObjectTag(Tag):
|
||||
"blend": self.blend,
|
||||
"update": self.update,
|
||||
"transform": self.transform.as_dict(*args, **kwargs) if self.transform is not None else None,
|
||||
"rotation_origin": self.rotation_origin.as_dict(*args, **kwargs)
|
||||
if self.rotation_origin is not None
|
||||
else None,
|
||||
"projection": "none"
|
||||
"rotation_origin": (
|
||||
self.rotation_origin.as_dict(*args, **kwargs) if self.rotation_origin is not None else None
|
||||
),
|
||||
"projection": (
|
||||
"none"
|
||||
if self.projection == self.PROJECTION_NONE
|
||||
else ("affine" if self.projection == self.PROJECTION_AFFINE else "perspective"),
|
||||
else ("affine" if self.projection == self.PROJECTION_AFFINE else "perspective")
|
||||
),
|
||||
"mult_color": self.mult_color.as_dict(*args, **kwargs) if self.mult_color is not None else None,
|
||||
"add_color": self.add_color.as_dict(*args, **kwargs) if self.add_color is not None else None,
|
||||
"hsl_shift": self.hsl_shift.as_dict(*args, **kwargs) if self.hsl_shift else None,
|
||||
|
@ -175,15 +175,17 @@ def viewevents() -> Response:
|
||||
"refresh": url_for("admin_pages.listevents", since=-1),
|
||||
"backfill": url_for("admin_pages.backfillevents", until=-1),
|
||||
"viewuser": url_for("admin_pages.viewuser", userid=-1),
|
||||
"jubeatsong": url_for("jubeat_pages.viewtopscores", musicid=-1)
|
||||
if GameConstants.JUBEAT in g.config.support
|
||||
else None,
|
||||
"iidxsong": url_for("iidx_pages.viewtopscores", musicid=-1)
|
||||
if GameConstants.IIDX in g.config.support
|
||||
else None,
|
||||
"pnmsong": url_for("popn_pages.viewtopscores", musicid=-1)
|
||||
"jubeatsong": (
|
||||
url_for("jubeat_pages.viewtopscores", musicid=-1) if GameConstants.JUBEAT in g.config.support else None
|
||||
),
|
||||
"iidxsong": (
|
||||
url_for("iidx_pages.viewtopscores", musicid=-1) if GameConstants.IIDX in g.config.support else None
|
||||
),
|
||||
"pnmsong": (
|
||||
url_for("popn_pages.viewtopscores", musicid=-1)
|
||||
if GameConstants.POPN_MUSIC in g.config.support
|
||||
else None,
|
||||
else None
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -10,7 +10,6 @@ from bemani.data import Data, Config, Score, Attempt, Link, Song, UserID, Remote
|
||||
|
||||
|
||||
class FrontendBase(ABC):
|
||||
|
||||
"""
|
||||
All subclasses should override this attribute with the string
|
||||
the game series uses in the DB.
|
||||
|
@ -20,9 +20,9 @@ class EAmuseProtocol:
|
||||
A wrapper object that encapsulates encoding/decoding the E-Amusement protocol by Konami.
|
||||
"""
|
||||
|
||||
SHARED_SECRET: Final[
|
||||
bytes
|
||||
] = b"\x69\xD7\x46\x27\xD9\x85\xEE\x21\x87\x16\x15\x70\xD0\x8D\x93\xB1\x24\x55\x03\x5B\x6D\xF0\xD8\x20\x5D\xF5"
|
||||
SHARED_SECRET: Final[bytes] = (
|
||||
b"\x69\xD7\x46\x27\xD9\x85\xEE\x21\x87\x16\x15\x70\xD0\x8D\x93\xB1\x24\x55\x03\x5B\x6D\xF0\xD8\x20\x5D\xF5"
|
||||
)
|
||||
|
||||
XML: Final[int] = 1
|
||||
BINARY: Final[int] = 2
|
||||
|
@ -71,8 +71,7 @@ class TestParallel(unittest.TestCase):
|
||||
|
||||
def test_class(self) -> None:
|
||||
class Base(ABC):
|
||||
def fun(self, x: int) -> int:
|
||||
...
|
||||
def fun(self, x: int) -> int: ...
|
||||
|
||||
class A(Base):
|
||||
def fun(self, x: int) -> int:
|
||||
|
@ -11,9 +11,9 @@ import struct
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
from sqlalchemy.engine import CursorResult # type: ignore
|
||||
from sqlalchemy.orm import sessionmaker # type: ignore
|
||||
from sqlalchemy.sql import text # type: ignore
|
||||
from sqlalchemy.exc import IntegrityError # type: ignore
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.sql import text
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||
|
||||
from bemani.common import (
|
||||
@ -1943,15 +1943,21 @@ class ImportPopn(ImportBase):
|
||||
"artist": read_string(unpacked[config.artist_offset]),
|
||||
"genre": read_string(unpacked[config.genre_offset]),
|
||||
"comment": read_string(unpacked[config.comment_offset]),
|
||||
"title_en": read_string(unpacked[config.english_title_offset])
|
||||
"title_en": (
|
||||
read_string(unpacked[config.english_title_offset])
|
||||
if config.english_title_offset is not None
|
||||
else "",
|
||||
"artist_en": read_string(unpacked[config.english_artist_offset])
|
||||
else ""
|
||||
),
|
||||
"artist_en": (
|
||||
read_string(unpacked[config.english_artist_offset])
|
||||
if config.english_artist_offset is not None
|
||||
else "",
|
||||
"long_genre": read_string(unpacked[config.extended_genre_offset])
|
||||
else ""
|
||||
),
|
||||
"long_genre": (
|
||||
read_string(unpacked[config.extended_genre_offset])
|
||||
if config.extended_genre_offset is not None
|
||||
else "",
|
||||
else ""
|
||||
),
|
||||
"folder": unpacked[config.folder_offset],
|
||||
"difficulty": {
|
||||
"standard": {
|
||||
@ -1967,24 +1973,28 @@ class ImportPopn(ImportBase):
|
||||
},
|
||||
"file": {
|
||||
"standard": {
|
||||
"easy": file_handle(config, unpacked[config.easy_file_offset])
|
||||
if valid_charts[0]
|
||||
else "",
|
||||
"normal": file_handle(config, unpacked[config.normal_file_offset])
|
||||
if valid_charts[1]
|
||||
else "",
|
||||
"hyper": file_handle(config, unpacked[config.hyper_file_offset])
|
||||
if valid_charts[2]
|
||||
else "",
|
||||
"easy": (
|
||||
file_handle(config, unpacked[config.easy_file_offset]) if valid_charts[0] else ""
|
||||
),
|
||||
"normal": (
|
||||
file_handle(config, unpacked[config.normal_file_offset]) if valid_charts[1] else ""
|
||||
),
|
||||
"hyper": (
|
||||
file_handle(config, unpacked[config.hyper_file_offset]) if valid_charts[2] else ""
|
||||
),
|
||||
"ex": file_handle(config, unpacked[config.ex_file_offset]) if valid_charts[3] else "",
|
||||
},
|
||||
"battle": {
|
||||
"normal": file_handle(config, unpacked[config.battle_normal_file_offset])
|
||||
"normal": (
|
||||
file_handle(config, unpacked[config.battle_normal_file_offset])
|
||||
if valid_charts[4]
|
||||
else "",
|
||||
"hyper": file_handle(config, unpacked[config.battle_hyper_file_offset])
|
||||
else ""
|
||||
),
|
||||
"hyper": (
|
||||
file_handle(config, unpacked[config.battle_hyper_file_offset])
|
||||
if valid_charts[5]
|
||||
else "",
|
||||
else ""
|
||||
),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1998,7 +2008,11 @@ class ImportPopn(ImportBase):
|
||||
# This is a removed song
|
||||
continue
|
||||
|
||||
if songinfo["title"] == "DUMMY" and songinfo["artist"] == "DUMMY" and songinfo["genre"] == "DUMMY":
|
||||
if (
|
||||
songinfo["title"] == "DUMMY"
|
||||
and songinfo["artist"] == "DUMMY"
|
||||
and songinfo["genre"] == "DUMMY"
|
||||
):
|
||||
# This is a song the intern left in
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user