1
0
mirror of synced 2025-02-20 20:50:59 +01:00

Fix a few more optional type errors.

This commit is contained in:
Jennifer Taylor 2021-05-31 18:14:51 +00:00
parent 38f0483cb5
commit b1b8b67fe3
3 changed files with 6 additions and 4 deletions

View File

@ -313,7 +313,10 @@ class MachineData(BaseData):
for owner in owners:
sql = "INSERT INTO arcade_owner (userid, arcadeid) VALUES(:userid, :arcadeid)"
self.execute(sql, {'userid': owner, 'arcadeid': arcadeid})
return self.get_arcade(arcadeid)
new_arcade = self.get_arcade(arcadeid)
if new_arcade is None:
raise Exception("Failed to create an arcade!")
return new_arcade
def get_arcade(self, arcadeid: ArcadeID) -> Optional[Arcade]:
"""

View File

@ -447,12 +447,11 @@ class MusicData(BaseData):
"SELECT music.songid AS songid, COUNT(score_history.timestamp) AS plays FROM score_history, music " +
"WHERE score_history.musicid = music.id AND music.game = :game AND music.version = :version "
)
timestamp: Optional[int] = None
if days is not None:
# Only select the last X days of hit chart
sql = sql + "AND score_history.timestamp > :timestamp "
timestamp = Time.now() - (Time.SECONDS_IN_DAY * days)
else:
timestamp = None
sql = sql + "GROUP BY songid ORDER BY plays DESC LIMIT :count"
cursor = self.execute(sql, {'game': game, 'version': version, 'count': count, 'timestamp': timestamp})

View File

@ -788,7 +788,7 @@ class BinaryEncoding:
else:
return None
def encode(self, tree: Node, encoding: str=None) -> bytes:
def encode(self, tree: Node, encoding: Optional[str]=None) -> bytes:
"""
Given a tree of Node objects, encode the data with the current encoding.