From 90cedcd5e143219e58fd0388e91fd86658d6072f Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Thu, 14 Aug 2025 01:52:48 +0000 Subject: [PATCH] Format with latest black, fix latest type issues. --- bemani/common/constants.py | 76 ++++++++++++++--------------- bemani/data/triggers.py | 2 +- bemani/format/afp/swf.py | 2 +- bemani/format/tdxt.py | 8 +-- bemani/frontend/bishi/endpoints.py | 44 ++++++++--------- bemani/frontend/popn/endpoints.py | 12 ++--- bemani/frontend/reflec/endpoints.py | 38 +++++++-------- bemani/protocol/protocol.py | 2 +- bemani/tests/test_XmlDecoder.py | 6 +-- bemani/utils/nvram.py | 2 +- 10 files changed, 96 insertions(+), 96 deletions(-) diff --git a/bemani/common/constants.py b/bemani/common/constants.py index c5a9132..5c34158 100644 --- a/bemani/common/constants.py +++ b/bemani/common/constants.py @@ -11,16 +11,16 @@ class GameConstants(Enum): in any of the tables should only contain one of the following strings. """ - BISHI_BASHI: Final[str] = "bishi" - DANCE_EVOLUTION: Final[str] = "danevo" - DDR: Final[str] = "ddr" - IIDX: Final[str] = "iidx" - JUBEAT: Final[str] = "jubeat" - MGA: Final[str] = "mga" - MUSECA: Final[str] = "museca" - POPN_MUSIC: Final[str] = "pnm" - REFLEC_BEAT: Final[str] = "reflec" - SDVX: Final[str] = "sdvx" + BISHI_BASHI = "bishi" + DANCE_EVOLUTION = "danevo" + DDR = "ddr" + IIDX = "iidx" + JUBEAT = "jubeat" + MGA = "mga" + MUSECA = "museca" + POPN_MUSIC = "pnm" + REFLEC_BEAT = "reflec" + SDVX = "sdvx" class VersionConstants: @@ -146,10 +146,10 @@ class APIConstants(Enum): The four types of IDs found in a BEMAPI request or response. """ - ID_TYPE_SERVER: Final[str] = "server" - ID_TYPE_CARD: Final[str] = "card" - ID_TYPE_SONG: Final[str] = "song" - ID_TYPE_INSTANCE: Final[str] = "instance" + ID_TYPE_SERVER = "server" + ID_TYPE_CARD = "card" + ID_TYPE_SONG = "song" + ID_TYPE_INSTANCE = "instance" class DBConstants: @@ -297,38 +297,38 @@ class BroadcastConstants(Enum): """ # Sections related to the player/song/etc. - DJ_NAME: Final[str] = "DJ Name" - SONG_NAME: Final[str] = "Song" - ARTIST_NAME: Final[str] = "Artist" - DIFFICULTY: Final[str] = "Difficulty" + DJ_NAME = "DJ Name" + SONG_NAME = "Song" + ARTIST_NAME = "Artist" + DIFFICULTY = "Difficulty" # Section headers. - PLAY_STATS_HEADER: Final[str] = "Play Stats" + PLAY_STATS_HEADER = "Play Stats" # Stats that relate to the song, but not the current play of the song. - TARGET_EXSCORE: Final[str] = "Target EXScore" - BEST_CLEAR_STATUS: Final[str] = "Best Clear" + TARGET_EXSCORE = "Target EXScore" + BEST_CLEAR_STATUS = "Best Clear" # Stats that have to do with the current play of the song. - EXSCORE: Final[str] = "Your EXScore" - CLEAR_STATUS: Final[str] = "Clear Status" - PERFECT_GREATS: Final[str] = "Perfect Greats" - GREATS: Final[str] = "Greats" - GOODS: Final[str] = "Goods" - BADS: Final[str] = "Bads" - POORS: Final[str] = "Poors" - COMBO_BREAKS: Final[str] = "Combo Breaks" - SLOWS: Final[str] = "Slow" - FASTS: Final[str] = "Fast" - GRADE: Final[str] = "Grade" - RATE: Final[str] = "Score Rate" + EXSCORE = "Your EXScore" + CLEAR_STATUS = "Clear Status" + PERFECT_GREATS = "Perfect Greats" + GREATS = "Greats" + GOODS = "Goods" + BADS = "Bads" + POORS = "Poors" + COMBO_BREAKS = "Combo Breaks" + SLOWS = "Slow" + FASTS = "Fast" + GRADE = "Grade" + RATE = "Score Rate" # Added for Pnm - PLAYER_NAME: Final[str] = "Player Name" - SCORE: Final[str] = "Your Score" - COOLS: Final[str] = "Cools" - COMBO: Final[str] = "Combo" - MEDAL: Final[str] = "Medal" + PLAYER_NAME = "Player Name" + SCORE = "Your Score" + COOLS = "Cools" + COMBO = "Combo" + MEDAL = "Medal" class _RegionConstants: diff --git a/bemani/data/triggers.py b/bemani/data/triggers.py index ab9f3ef..b694cdb 100644 --- a/bemani/data/triggers.py +++ b/bemani/data/triggers.py @@ -1,5 +1,5 @@ from datetime import datetime -from discord_webhook import DiscordWebhook, DiscordEmbed +from discord_webhook import DiscordWebhook, DiscordEmbed # type: ignore from typing import Dict from bemani.common.constants import GameConstants, BroadcastConstants diff --git a/bemani/format/afp/swf.py b/bemani/format/afp/swf.py index a72dc06..5ee8e6e 100644 --- a/bemani/format/afp/swf.py +++ b/bemani/format/afp/swf.py @@ -2733,7 +2733,7 @@ class SWF(VerboseOutput, TrackedCoverage): ap2_data_version = magic[0] & 0xFF magic = bytes([magic[3] & 0x7F, magic[2] & 0x7F, magic[1] & 0x7F, 0x0]) if magic != b"AP2\x00": - raise Exception(f"Unrecognzied magic {magic}!") + raise Exception(f"Unrecognzied magic {magic!r}!") if length != len(data): raise Exception(f"Unexpected length in AFP header, {length} != {len(data)}!") if ap2_data_version not in [7, 8, 9, 10]: diff --git a/bemani/format/tdxt.py b/bemani/format/tdxt.py index 374cb3b..3b193eb 100644 --- a/bemani/format/tdxt.py +++ b/bemani/format/tdxt.py @@ -382,7 +382,7 @@ class TDXT: | ((pixel[order[2]] >> 3) & 0x1F) ), ) - for pixel in imgdata.getdata() + for pixel in imgdata.getdata() # type: ignore ) elif self.fmt == 0x13: # 16-bit A1R5G55 texture format. @@ -396,7 +396,7 @@ class TDXT: | ((pixel[order[2]] >> 3) & 0x1F) ), ) - for pixel in imgdata.getdata() + for pixel in imgdata.getdata() # type: ignore ) elif self.fmt == 0x1F: # 16-bit 4-4-4-4 RGBA format. @@ -410,7 +410,7 @@ class TDXT: | (((pixel[3] >> 4) & 0xF) << 12) ), ) - for pixel in imgdata.getdata() + for pixel in imgdata.getdata() # type: ignore ) elif self.fmt == 0x20: # 32-bit RGBA format, stored in BGRA order. @@ -422,7 +422,7 @@ class TDXT: pixel[order[0]], pixel[3], ) - for pixel in imgdata.getdata() + for pixel in imgdata.getdata() # type: ignore ) else: raise Exception(f"Unsupported format {hex(self.fmt)} for TDXT file!") diff --git a/bemani/frontend/bishi/endpoints.py b/bemani/frontend/bishi/endpoints.py index bc10654..5c941b0 100644 --- a/bemani/frontend/bishi/endpoints.py +++ b/bemani/frontend/bishi/endpoints.py @@ -136,31 +136,31 @@ def updatename() -> Dict[str, Any]: if ( re.match( "^[" - + "\uFF20-\uFF3A" - + "\uFF10-\uFF19" # widetext A-Z, @ - + "\u3041-\u308D\u308F\u3092\u3093" # widetext 0-9 - + "\u30A1-\u30ED\u30EF\u30F2\u30F3\u30FC" # hiragana + + "\uff20-\uff3a" + + "\uff10-\uff19" # widetext A-Z, @ + + "\u3041-\u308d\u308f\u3092\u3093" # widetext 0-9 + + "\u30a1-\u30ed\u30ef\u30f2\u30f3\u30fc" # hiragana + "\u3000" # katakana - + "\u301C" # widetext blank space - + "\u30FB" # widetext ~ - + "\u30FC" # widetext middot + + "\u301c" # widetext blank space + + "\u30fb" # widetext ~ + + "\u30fc" # widetext middot + "\u2212" # widetext long dash + "\u2605" # widetext short dash - + "\uFF01" # widetext heavy star - + "\uFF03" # widetext ! - + "\uFF04" # widetext # - + "\uFF05" # widetext $ - + "\uFF06" # widetext % - + "\uFF08" # widetext & - + "\uFF09" # widetext ( - + "\uFF0A" # widetext ) - + "\uFF0B" # widetext * - + "\uFF0F" # widetext + - + "\uFF1C" # widetext / - + "\uFF1D" # widetext < - + "\uFF1E" # widetext = - + "\uFF1F" # widetext > - + "\uFFE5" # widetext ? + + "\uff01" # widetext heavy star + + "\uff03" # widetext ! + + "\uff04" # widetext # + + "\uff05" # widetext $ + + "\uff06" # widetext % + + "\uff08" # widetext & + + "\uff09" # widetext ( + + "\uff0a" # widetext ) + + "\uff0b" # widetext * + + "\uff0f" # widetext + + + "\uff1c" # widetext / + + "\uff1d" # widetext < + + "\uff1e" # widetext = + + "\uff1f" # widetext > + + "\uffe5" # widetext ? + "]*$", # widetext Yen symbol name, ) diff --git a/bemani/frontend/popn/endpoints.py b/bemani/frontend/popn/endpoints.py index f07c593..ad5d82f 100644 --- a/bemani/frontend/popn/endpoints.py +++ b/bemani/frontend/popn/endpoints.py @@ -335,12 +335,12 @@ def updatename() -> Dict[str, Any]: if ( re.match( "^[" - + "\uFF20-\uFF3A" - + "\uFF41-\uFF5A" # widetext A-Z and @ - + "\uFF10-\uFF19" # widetext a-z - + "\uFF0C\uFF0E\uFF3F" # widetext 0-9 - + "\u3041-\u308D\u308F\u3092\u3093" # widetext ,._ - + "\u30A1-\u30ED\u30EF\u30F2\u30F3\u30FC" # hiragana + + "\uff20-\uff3a" + + "\uff41-\uff5a" # widetext A-Z and @ + + "\uff10-\uff19" # widetext a-z + + "\uff0c\uff0e\uff3f" # widetext 0-9 + + "\u3041-\u308d\u308f\u3092\u3093" # widetext ,._ + + "\u30a1-\u30ed\u30ef\u30f2\u30f3\u30fc" # hiragana + "]*$", # katakana name, ) diff --git a/bemani/frontend/reflec/endpoints.py b/bemani/frontend/reflec/endpoints.py index 585002c..9eb7919 100644 --- a/bemani/frontend/reflec/endpoints.py +++ b/bemani/frontend/reflec/endpoints.py @@ -332,15 +332,15 @@ def updatename() -> Dict[str, Any]: if ( re.match( "^[" - + "\uFF21-\uFF3A" - + "\uFF10-\uFF19" # widetext A-Z - + "\uFF0E\u2212\uFF3F\u30FB" # widetext 0-9 - + "\uFF06\uFF01\uFF1F\uFF0F" - + "\uFF0A\uFF03\u266D\u2605" - + "\uFF20\u266A\u2193\u2191" - + "\u2192\u2190\uFF08\uFF09" - + "\u221E\u25C6\u25CF\u25BC" - + "\uFFE5\uFF3E\u2200\uFF05" + + "\uff21-\uff3a" + + "\uff10-\uff19" # widetext A-Z + + "\uff0e\u2212\uff3f\u30fb" # widetext 0-9 + + "\uff06\uff01\uff1f\uff0f" + + "\uff0a\uff03\u266d\u2605" + + "\uff20\u266a\u2193\u2191" + + "\u2192\u2190\uff08\uff09" + + "\u221e\u25c6\u25cf\u25bc" + + "\uffe5\uff3e\u2200\uff05" + "\u3000" + "]*$", # widetext space name, @@ -354,16 +354,16 @@ def updatename() -> Dict[str, Any]: if ( re.match( "^[" - + "\uFF21-\uFF3A" - + "\uFF41-\uFF5A" # widetext A-Z - + "\uFF10-\uFF19" # widetext a-z - + "\uFF0E\u2212\uFF3F\u30FB" # widetext 0-9 - + "\uFF06\uFF01\uFF1F\uFF0F" - + "\uFF0A\uFF03\u266D\u2605" - + "\uFF20\u266A\u2193\u2191" - + "\u2192\u2190\uFF08\uFF09" - + "\u221E\u25C6\u25CF\u25BC" - + "\uFFE5\uFF3E\u2200\uFF05" + + "\uff21-\uff3a" + + "\uff41-\uff5a" # widetext A-Z + + "\uff10-\uff19" # widetext a-z + + "\uff0e\u2212\uff3f\u30fb" # widetext 0-9 + + "\uff06\uff01\uff1f\uff0f" + + "\uff0a\uff03\u266d\u2605" + + "\uff20\u266a\u2193\u2191" + + "\u2192\u2190\uff08\uff09" + + "\u221e\u25c6\u25cf\u25bc" + + "\uffe5\uff3e\u2200\uff05" + "\u3000" + "]*$", # widetext space name, diff --git a/bemani/protocol/protocol.py b/bemani/protocol/protocol.py index 4cbced8..fcb863d 100644 --- a/bemani/protocol/protocol.py +++ b/bemani/protocol/protocol.py @@ -21,7 +21,7 @@ class EAmuseProtocol: """ 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" + 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 diff --git a/bemani/tests/test_XmlDecoder.py b/bemani/tests/test_XmlDecoder.py index 05b7e61..075512b 100644 --- a/bemani/tests/test_XmlDecoder.py +++ b/bemani/tests/test_XmlDecoder.py @@ -73,7 +73,7 @@ class TestXmlDecoder(unittest.TestCase): self.assertEqual(tree.name, "node") self.assertEqual(tree.attributes, {}) self.assertEqual(tree.data_type, "bin") - self.assertEqual(tree.value, b"\xDE\xAD\xBE\xEF") + self.assertEqual(tree.value, b"\xde\xad\xbe\xef") xml = XmlDecoder(b'\nDEADBEEF\n', "ascii") tree = xml.get_tree() @@ -82,7 +82,7 @@ class TestXmlDecoder(unittest.TestCase): self.assertEqual(tree.name, "node") self.assertEqual(tree.attributes, {}) self.assertEqual(tree.data_type, "bin") - self.assertEqual(tree.value, b"\xDE\xAD\xBE\xEF") + self.assertEqual(tree.value, b"\xde\xad\xbe\xef") xml = XmlDecoder(b' D E A D B E E F ', "ascii") tree = xml.get_tree() @@ -91,7 +91,7 @@ class TestXmlDecoder(unittest.TestCase): self.assertEqual(tree.name, "node") self.assertEqual(tree.attributes, {}) self.assertEqual(tree.data_type, "bin") - self.assertEqual(tree.value, b"\xDE\xAD\xBE\xEF") + self.assertEqual(tree.value, b"\xde\xad\xbe\xef") def test_decode_array(self) -> None: xml = XmlDecoder(b'1 2 3 4', "ascii") diff --git a/bemani/utils/nvram.py b/bemani/utils/nvram.py index f4cbcfe..c9bade0 100644 --- a/bemani/utils/nvram.py +++ b/bemani/utils/nvram.py @@ -50,7 +50,7 @@ def main() -> None: if args.no_reset: chunks = [data] else: - chunks = [data[x:x + 768] for x in range(0, len(data), 768)] + chunks = [data[x : x + 768] for x in range(0, len(data), 768)] outputs = [] proto = EAmuseProtocol()