Apply more rigorous type checking, fix a few bugs caught with that more rigorous type checking.

This commit is contained in:
Jennifer Taylor
2021-08-20 18:10:07 +00:00
parent 97bea03abe
commit b572689107
7 changed files with 24 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
from typing import Optional, Any
from bemani.backend.base import Model, Base, Status
from bemani.backend.base import Base, Status
from bemani.common import Model
from bemani.protocol import Node
from bemani.data import Config, Data

View File

@@ -2634,8 +2634,8 @@ class ByteCodeDecompiler(VerboseOutput):
if isinstance(statement, GotoStatement):
if statement.location in labels:
return NullReturnStatement()
updated = True
return NullReturnStatement()
return statement
statements = self.__walk(statements, update_gotos)

View File

@@ -73,7 +73,7 @@ class TrackedCoverage:
def get_uncovered_chunks(self, req_start: Optional[int] = None, req_end: Optional[int] = None, adjust_offsets: bool = False) -> List[Tuple[int, int]]:
# First offset that is not coverd in a run.
start = None
start: Optional[int] = None
chunks: List[Tuple[int, int]] = []
for offset, covered in enumerate(self.coverage):

View File

@@ -631,8 +631,8 @@ def generatepcbid() -> Dict[str, Any]:
raise Exception('Unable to find arcade to link PCBID to!')
# Will be set by the game on boot.
name = 'なし'
pcbid = None
name: str = 'なし'
pcbid: Optional[str] = None
while pcbid is None:
# Generate a new PCBID, check for uniqueness
potential_pcbid = "01201000000000" + "".join([random.choice("0123456789ABCDEF") for _ in range(6)])

View File

@@ -165,10 +165,14 @@ def receive_request(path: str) -> Response:
}
# Copy over required headers that are sent by game client.
if request_compression is not None:
if request_compression:
headers['X-Compress'] = request_compression
if request_encryption is not None:
else:
headers['X-Compress'] = 'none'
if request_encryption:
headers['X-Eamuse-Info'] = request_encryption
# Make sure to copy the user agent as well.
if request_client is not None:
headers['User-Agent'] = request_client

View File

@@ -68,8 +68,6 @@ def receive_request(path: str) -> Response:
)
return Response("No response generated", 404)
compression = None
data = proto.encode(
compression,
encryption,

View File

@@ -41,9 +41,21 @@ MYPYPATH=$(python -c "import os; print(os.path.realpath('.'))") mypy \
"${cmdline[@]}" \
--warn-redundant-casts \
--warn-unused-ignores \
--warn-unused-configs \
--warn-unreachable \
--disallow-untyped-calls \
--disallow-untyped-defs \
--disallow-subclassing-any \
--disallow-incomplete-defs \
--disallow-untyped-decorators \
--check-untyped-defs \
--strict-equality \
--no-implicit-reexport \
--no-implicit-optional \
--no-strict-optional
# Currently we are missing the following options to make us "strict":
# --disallow-any-generics - Currently impossible to type certain generics such as Callable.
# --warn-return-any - This finds a lot of code that we know is correct but mypy can't prove, not worth it.
# We also would want to get rid of the following options:
# --no-strict-optional - We have a lot of code that doesn't check but should check for optional.