Skip to content

Commit

Permalink
Added more type ignore for mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
squaresmile committed Jul 12, 2024
1 parent 11a3284 commit b7b15d1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/db/helpers/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ async def get_ai_entity(
func.jsonb_build_object(
"svt" if ai_table is mstAi else "field",
func.coalesce(
func.array_remove(array_agg(ai_table.c.id.distinct()), None),
func.array_remove(array_agg(ai_table.c.id.distinct()), None), # type: ignore[no-untyped-call]
[],
),
"field" if ai_table is mstAi else "svt",
cast(array([]), ARRAY(Integer)),
cast(array([]), ARRAY(Integer)), # type: ignore[no-untyped-call]
)
)
.select_from(ai_table)
Expand Down
14 changes: 7 additions & 7 deletions app/db/helpers/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def get_rayshift_phases_cte(

def get_rayshift_phase_with_enemy_select(rayshift_cte: CTE) -> Label[Any]:
return func.to_jsonb(
func.array_remove(array_agg(rayshift_cte.c.phase.distinct()), None)
func.array_remove(array_agg(rayshift_cte.c.phase.distinct()), None) # type: ignore[no-untyped-call]
).label("phasesWithEnemies")


Expand Down Expand Up @@ -500,7 +500,7 @@ def get_rayshift_phase_with_enemy_select(rayshift_cte: CTE) -> Label[Any]:
mstQuestPhase.c.phase,
),
).distinct()
),
), # type: ignore[no-untyped-call]
None,
).label("phasesNoBattle")

Expand All @@ -516,11 +516,11 @@ def get_rayshift_phase_with_enemy_select(rayshift_cte: CTE) -> Label[Any]:
sql_jsonb_agg(mstGiftAddAlias, "mstGiftAdd"),
sql_jsonb_agg(mstQuestPhasePresent, "mstQuestPhasePresent"),
func.to_jsonb(
func.array_remove(array_agg(mstQuestPhase.c.phase.distinct()), None)
func.array_remove(array_agg(mstQuestPhase.c.phase.distinct()), None) # type: ignore[no-untyped-call]
).label("phases"),
phasesNoBattle,
func.to_jsonb(
func.array_remove(array_agg(scripts_cte.table_valued().distinct()), None)
func.array_remove(array_agg(scripts_cte.table_valued().distinct()), None) # type: ignore[no-untyped-call]
).label("allScripts"),
]

Expand Down Expand Up @@ -682,7 +682,7 @@ async def get_quest_phase_entity(
)

phasesWithEnemies_select = func.coalesce(
select(func.array_remove(array_agg(rayshiftQuest.c.phase.distinct()), None))
select(func.array_remove(array_agg(rayshiftQuest.c.phase.distinct()), None)) # type: ignore[no-untyped-call]
.select_from(rayshiftQuest)
.where(rayshiftQuest.c.questId == quest_id)
.scalar_subquery(),
Expand All @@ -693,7 +693,7 @@ async def get_quest_phase_entity(
(
select(
func.array_remove(
array_agg(ScriptFileList.c.scriptFileName.distinct()), None
array_agg(ScriptFileList.c.scriptFileName.distinct()), None # type: ignore[no-untyped-call]
)
)
.select_from(ScriptFileList)
Expand Down Expand Up @@ -722,7 +722,7 @@ async def get_quest_phase_entity(
"sceneType",
ScriptFileList.c.sceneType,
).distinct()
)
) # type: ignore[no-untyped-call]
)
.select_from(ScriptFileList)
.where(ScriptFileList.c.questId == quest_id)
Expand Down
6 changes: 3 additions & 3 deletions app/db/helpers/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def get_skillEntity(
select(
mstSkillLv.c.skillId,
func.jsonb_agg(
aggregate_order_by(mstSkillLv.table_valued(), mstSkillLv.c.lv)
aggregate_order_by(mstSkillLv.table_valued(), mstSkillLv.c.lv) # type: ignore[no-untyped-call]
).label(mstSkillLv.name),
)
.where(mstSkillLv.c.skillId.in_(skill_ids))
Expand All @@ -44,12 +44,12 @@ async def get_skillEntity(
func.jsonb_build_object(
"svt",
func.coalesce(
func.array_remove(array_agg(mstAi.c.id.distinct()), None),
func.array_remove(array_agg(mstAi.c.id.distinct()), None), # type: ignore[no-untyped-call]
[],
),
"field",
func.coalesce(
func.array_remove(array_agg(mstAiField.c.id.distinct()), None),
func.array_remove(array_agg(mstAiField.c.id.distinct()), None), # type: ignore[no-untyped-call]
[],
),
).label("aiIds"),
Expand Down
2 changes: 1 addition & 1 deletion app/db/helpers/td.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def get_tdEntity(
func.jsonb_agg(
aggregate_order_by(
mstTreasureDeviceLv.table_valued(), mstTreasureDeviceLv.c.lv
)
) # type: ignore[no-untyped-call]
).label(mstTreasureDeviceLv.name),
)
.where(mstTreasureDeviceLv.c.treaureDeviceId.in_(td_ids))
Expand Down
2 changes: 1 addition & 1 deletion app/db/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def sql_jsonb_agg(
) -> _ColumnsClauseArgument[JSONB]:
"""Equivalent to `func.JSONB_AGG` but removes empty elements from the output"""
return func.to_jsonb(
func.array_remove(array_agg(table.table_valued().distinct()), None)
func.array_remove(array_agg(table.table_valued().distinct()), None) # type: ignore[no-untyped-call]
).label(label if label else table.name)


Expand Down
6 changes: 3 additions & 3 deletions app/redis/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def load_svt_extra_redis(
for svtExtra in svtExtras
}
await redis.delete(redis_key)
await redis.hset(redis_key, mapping=svtExtra_redis_data)
await redis.hset(redis_key, mapping=svtExtra_redis_data) # type: ignore[arg-type]


async def load_mstBuff(
Expand All @@ -69,7 +69,7 @@ async def load_mstBuff(
k: zstd_compress(v.json().encode("utf-8")) for k, v in mstBuff_data.items()
}
await redis.delete(redis_key)
await redis.hset(redis_key, mapping=mstBuff_redis)
await redis.hset(redis_key, mapping=mstBuff_redis) # type: ignore[arg-type]


@dataclass
Expand Down Expand Up @@ -101,7 +101,7 @@ async def load_reverse_data(
}
redis_key = f"{redis_prefix}:{region.name}:{data.key.name}"
await redis.delete(redis_key)
await redis.hset(redis_key, mapping=redis_data)
await redis.hset(redis_key, mapping=redis_data) # type: ignore[arg-type]


async def load_redis_data(
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def event_loop() -> Generator[AbstractEventLoop, None, None]:
https://github.com/pytest-dev/pytest-asyncio/issues/171
"""
if platform.system() == "Windows":
policy: AbstractEventLoopPolicy = asyncio.WindowsSelectorEventLoopPolicy()
policy: AbstractEventLoopPolicy = asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]
else:
policy = asyncio.get_event_loop_policy()
loop = policy.new_event_loop()
Expand Down
2 changes: 1 addition & 1 deletion tests/get_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ async def main(
args = parser.parse_args()

if platform.system() == "Windows":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore[attr-defined]

asyncio.run(main(args.raw, args.nice, args.basic, args.test))

0 comments on commit b7b15d1

Please sign in to comment.