Apply Final to a few more miscelaneous classes outside of frontend.
This commit is contained in:
parent
469df34bea
commit
3863b9f048
@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import Optional, Dict, List, Tuple, Any
|
||||
from typing_extensions import Final
|
||||
|
||||
from bemani.client.common import random_hex_string
|
||||
from bemani.client.protocol import ClientProtocol
|
||||
@ -13,13 +14,13 @@ class BaseClient:
|
||||
and verify some basic packets that are always expected to work.
|
||||
"""
|
||||
|
||||
CARD_OK = 0
|
||||
CARD_NEW = 112
|
||||
CARD_BAD_PIN = 116
|
||||
CARD_NOT_ALLOWED = 110
|
||||
CARD_OK: Final[int] = 0
|
||||
CARD_NEW: Final[int] = 112
|
||||
CARD_BAD_PIN: Final[int] = 116
|
||||
CARD_NOT_ALLOWED: Final[int] = 110
|
||||
|
||||
CORRECT_PASSWORD = '1234'
|
||||
WRONG_PASSWORD = '4321'
|
||||
CORRECT_PASSWORD: Final[str] = '1234'
|
||||
WRONG_PASSWORD: Final[str] = '4321'
|
||||
|
||||
def __init__(self, proto: ClientProtocol, pcbid: str, config: Dict[str, Any]) -> None:
|
||||
self.__proto = proto
|
||||
|
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import requests
|
||||
from typing import Tuple, Dict, List, Any, Optional
|
||||
from typing_extensions import Final
|
||||
|
||||
from bemani.common import APIConstants, GameConstants, VersionConstants, DBConstants, ValidatedDict
|
||||
|
||||
@ -34,7 +35,7 @@ class APIClient:
|
||||
A client that fully speaks BEMAPI and can pull information from a remote server.
|
||||
"""
|
||||
|
||||
API_VERSION = 'v1'
|
||||
API_VERSION: Final[str] = 'v1'
|
||||
|
||||
def __init__(self, base_uri: str, token: str, allow_stats: bool, allow_scores: bool) -> None:
|
||||
self.base_uri = base_uri
|
||||
|
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import random
|
||||
from typing import Dict, Any, Optional
|
||||
from typing_extensions import Final
|
||||
|
||||
from bemani.common import Time
|
||||
from bemani.data.config import Config
|
||||
@ -38,7 +39,7 @@ class _BytesEncoder(json.JSONEncoder):
|
||||
|
||||
class BaseData:
|
||||
|
||||
SESSION_LENGTH = 32
|
||||
SESSION_LENGTH: Final[int] = 32
|
||||
|
||||
def __init__(self, config: Config, conn: Connection) -> None:
|
||||
"""
|
||||
|
@ -4,6 +4,7 @@ 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 typing import Optional, Dict, List, Tuple, Any
|
||||
from typing_extensions import Final
|
||||
from passlib.hash import pbkdf2_sha512 # type: ignore
|
||||
|
||||
from bemani.common import ValidatedDict, Profile, GameConstants, Time
|
||||
@ -165,7 +166,7 @@ class AccountCreationException(Exception):
|
||||
|
||||
class UserData(BaseData):
|
||||
|
||||
REF_ID_LENGTH = 16
|
||||
REF_ID_LENGTH: Final[int] = 16
|
||||
|
||||
def from_cardid(self, cardid: str) -> Optional[UserID]:
|
||||
"""
|
||||
|
@ -1,5 +1,6 @@
|
||||
import struct
|
||||
from typing import List, Optional, Tuple
|
||||
from typing_extensions import Final
|
||||
|
||||
|
||||
class IIDXChart:
|
||||
@ -11,7 +12,7 @@ class IIDXChart:
|
||||
clear ranks for IIDX.
|
||||
"""
|
||||
|
||||
CHART_POSITIONS = [1, 0, 2, 7, 6, 8]
|
||||
CHART_POSITIONS: Final[List[int]] = [1, 0, 2, 7, 6, 8]
|
||||
|
||||
def __init__(self, data: bytes) -> None:
|
||||
self.__bpm_min: Optional[int] = None
|
||||
|
@ -1,6 +1,7 @@
|
||||
import socket
|
||||
import struct
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing_extensions import Final
|
||||
|
||||
|
||||
class InvalidPacketException(Exception):
|
||||
@ -23,8 +24,8 @@ class TCPStream:
|
||||
SYN -> SYNACK -> ACK flow followed by some data followed by a FIN -> FINACK -> ACK
|
||||
flow. Luckily, this is exactly what most HTTP requests look like.
|
||||
"""
|
||||
INBOUND = 'inbound'
|
||||
OUTBOUND = 'outbound'
|
||||
INBOUND: Final[str] = 'inbound'
|
||||
OUTBOUND: Final[str] = 'outbound'
|
||||
|
||||
def __init__(self, packet: Dict[str, Any]) -> None:
|
||||
"""
|
||||
@ -196,10 +197,10 @@ class Sniffer:
|
||||
A generic python sniffer. Listens to all raw traffic on the machine and parses packets
|
||||
down to TCP chunks to be reassembled.
|
||||
"""
|
||||
RECEIVE_SIZE = 1048576
|
||||
ETH_HEADER_LENGTH = 14
|
||||
IP_HEADER_LENGTH = 20
|
||||
TCP_HEADER_LENGTH = 20
|
||||
RECEIVE_SIZE: Final[int] = 1048576
|
||||
ETH_HEADER_LENGTH: Final[int] = 14
|
||||
IP_HEADER_LENGTH: Final[int] = 20
|
||||
TCP_HEADER_LENGTH: Final[int] = 20
|
||||
|
||||
def __init__(self, address: Optional[str]=None, port: Optional[int]=None) -> None:
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user