diff --git a/.pyre_configuration b/.pyre_configuration index 5e7dc630..6c670b47 100644 --- a/.pyre_configuration +++ b/.pyre_configuration @@ -8,6 +8,10 @@ { "import_root": ".", "source": "examples" + }, + { + "import_root": ".", + "source": "test" } ] } diff --git a/test/autotest_bot.py b/test/autotest_bot.py index fe71bf6e..16e5e767 100644 --- a/test/autotest_bot.py +++ b/test/autotest_bot.py @@ -1,6 +1,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) from loguru import logger @@ -487,6 +488,7 @@ async def on_start(self): await self.client.debug_kill_unit(self.units) async def on_step(self, iteration: int): + # pyre-ignore[16] map_center = self.game_info.map_center enemies = self.enemy_units | self.enemy_structures if enemies: diff --git a/test/benchmark_distance_two_points.py b/test/benchmark_distance_two_points.py index 7e6999e9..315422fe 100644 --- a/test/benchmark_distance_two_points.py +++ b/test/benchmark_distance_two_points.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[21] import math import platform import random diff --git a/test/benchmark_distances_cdist.py b/test/benchmark_distances_cdist.py index 6314ee6b..fdcfd7b8 100644 --- a/test/benchmark_distances_cdist.py +++ b/test/benchmark_distances_cdist.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[21] import random import numpy as np diff --git a/test/benchmark_distances_points_to_point.py b/test/benchmark_distances_points_to_point.py index f04d5849..cd36c8d8 100644 --- a/test/benchmark_distances_points_to_point.py +++ b/test/benchmark_distances_points_to_point.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[21] from __future__ import annotations import math diff --git a/test/benchmark_distances_units.py b/test/benchmark_distances_units.py index c281045a..11d81462 100644 --- a/test/benchmark_distances_units.py +++ b/test/benchmark_distances_units.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[21] import math import random diff --git a/test/damagetest_bot.py b/test/damagetest_bot.py index 09f46a6a..b56f7565 100644 --- a/test/damagetest_bot.py +++ b/test/damagetest_bot.py @@ -1,6 +1,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) import math @@ -323,6 +324,7 @@ async def on_start(self): await self.client.debug_kill_unit(self.units) async def on_step(self, iteration: int): + # pyre-ignore[16] map_center = self.game_info.map_center enemies = self.enemy_units | self.enemy_structures if enemies: diff --git a/test/generate_pickle_files_bot.py b/test/generate_pickle_files_bot.py index df5e4626..fce168be 100644 --- a/test/generate_pickle_files_bot.py +++ b/test/generate_pickle_files_bot.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[16] """ This "bot" will loop over several available ladder maps and generate the pickle file in the "/test/pickle_data/" subfolder. These will then be used to run tests from the test script "test_pickled_data.py" @@ -8,6 +9,7 @@ from pathlib import Path from loguru import logger +# pyre-ignore[21] from s2clientprotocol import sc2api_pb2 as sc_pb from sc2 import maps @@ -30,14 +32,14 @@ def __init__(self): async def on_step(self, iteration): pass - def get_pickle_file_path(self) -> str: + def get_pickle_file_path(self) -> Path: folder_path = Path(__file__).parent subfolder_name = "pickle_data" file_name = f"{self.map_name}.xz" file_path = folder_path / subfolder_name / file_name return file_path - def get_combat_file_path(self) -> str: + def get_combat_file_path(self) -> Path: folder_path = Path(__file__).parent subfolder_name = "combat_data" file_name = f"{self.map_name}.xz" diff --git a/test/queries_test_bot.py b/test/queries_test_bot.py index 806c1395..cce224d2 100644 --- a/test/queries_test_bot.py +++ b/test/queries_test_bot.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[16] """ This testbot's purpose is to test the query behavior of the API. These query functions are: @@ -10,6 +11,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) diff --git a/test/real_time_worker_production.py b/test/real_time_worker_production.py index 0d9daf44..4dd207c7 100644 --- a/test/real_time_worker_production.py +++ b/test/real_time_worker_production.py @@ -5,6 +5,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) import asyncio @@ -94,6 +95,7 @@ async def on_building_construction_complete(self, unit: Unit): if unit.is_structure: unit(AbilityId.RALLY_WORKERS, self.mineral_field.closest_to(unit)) + # pyre-ignore[11] async def on_end(self, game_result: Result): global on_end_was_called on_end_was_called = True diff --git a/test/run_example_bots_vs_computer.py b/test/run_example_bots_vs_computer.py index 7129dc69..2a91f2a3 100644 --- a/test/run_example_bots_vs_computer.py +++ b/test/run_example_bots_vs_computer.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[16] """ This script makes sure to run all bots in the examples folder to check if they can launch. """ @@ -7,6 +8,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) import asyncio from importlib import import_module @@ -118,6 +120,7 @@ # Run example bots for bot_info in bot_infos: + # pyre-ignore[11] bot_race: Race = bot_info["race"] bot_path: str = bot_info["path"] bot_class_name: str = bot_info["bot_class_name"] diff --git a/test/run_example_bots_vs_each_other.py b/test/run_example_bots_vs_each_other.py index 4d447542..12b13fb2 100644 --- a/test/run_example_bots_vs_each_other.py +++ b/test/run_example_bots_vs_each_other.py @@ -1,3 +1,4 @@ +# pyre-ignore-all-errors[16] """ This script makes sure to run all bots in the examples folder to check if they can launch against each other. """ @@ -7,6 +8,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) import asyncio from importlib import import_module @@ -99,6 +101,7 @@ # Run bots against each other for bot_info1, bot_info2 in combinations(bot_infos, 2): + # pyre-ignore[11] bot_race1: Race = bot_info1["race"] bot_path: str = bot_info1["path"] bot_class_name: str = bot_info1["bot_class_name"] diff --git a/test/test_pickled_data.py b/test/test_pickled_data.py index 5bb30799..6db2df7d 100644 --- a/test/test_pickled_data.py +++ b/test/test_pickled_data.py @@ -21,6 +21,7 @@ from pathlib import Path from typing import Any +# pyre-ignore[21] from google.protobuf.internal import api_implementation from hypothesis import given, settings from hypothesis import strategies as st @@ -292,12 +293,14 @@ def test_bot_ai(): def calc_cost(item_id) -> Cost: if isinstance(item_id, AbilityId): + # pyre-ignore[16] return bot.game_data.calculate_ability_cost(item_id) elif isinstance(item_id, UpgradeId): return bot.game_data.upgrades[item_id.value].cost elif isinstance(item_id, UnitTypeId): creation_ability: AbilityId = bot.game_data.units[item_id.value].creation_ability.exact_id return bot.game_data.calculate_ability_cost(creation_ability) + return Cost(0, 0) def assert_cost(item_id, real_cost: Cost): assert calc_cost(item_id) == real_cost, f"Cost of {item_id} should be {real_cost} but is {calc_cost(item_id)}" diff --git a/test/test_pickled_ramp.py b/test/test_pickled_ramp.py index 6ad9c477..a1294d2a 100644 --- a/test/test_pickled_ramp.py +++ b/test/test_pickled_ramp.py @@ -38,6 +38,7 @@ class TestClass: def test_main_base_ramp(self, map_path: Path): bot = get_map_specific_bot(map_path) + # pyre-ignore[16] bot.game_info.map_ramps, bot.game_info.vision_blockers = bot.game_info._find_ramps_and_vision_blockers() # Test if main ramp works for all spawns @@ -103,6 +104,7 @@ def test_bot_ai(self, map_path: Path): ), f"Too many expansions found: {len(bot.expansion_locations_list)}" # On N player maps, it is expected that there are N*X bases because of symmetry, at least for maps designed for 1vs1 # Those maps in the list have an un-even expansion count + # pyre-ignore[16] expect_even_expansion_count = 1 if bot.game_info.map_name in ["StargazersAIE", "Stasis LE"] else 0 assert ( len(bot.expansion_locations_list) % (len(bot.enemy_start_locations) + 1) == expect_even_expansion_count @@ -115,6 +117,7 @@ def test_bot_ai(self, map_path: Path): for location in bot.enemy_start_locations: assert location in set(bot.expansion_locations_list), f"{location}, {bot.expansion_locations_list}" # Each expansion is supposed to have at least one geysir and 6-12 minerals + # pyre-ignore[16] for expansion, resource_positions in bot.expansion_locations_dict.items(): assert isinstance(expansion, Point2) assert isinstance(resource_positions, Units) diff --git a/test/travis_test_script.py b/test/travis_test_script.py index 76b232d3..44028820 100644 --- a/test/travis_test_script.py +++ b/test/travis_test_script.py @@ -49,16 +49,20 @@ # Break as the bot run was successful break + # pyre-ignore[16] if process.returncode is not None: # Reformat the output into a list - logger.info_output: str = result + # pyre-ignore[16] + logger.info_output = result linebreaks = [ + # pyre-ignore[16] ["\r\n", logger.info_output.count("\r\n")], ["\r", logger.info_output.count("\r")], ["\n", logger.info_output.count("\n")], ] most_linebreaks_type = max(linebreaks, key=lambda x: x[1]) linebreak_type, linebreak_count = most_linebreaks_type + # pyre-ignore[16] output_as_list = logger.info_output.split(linebreak_type) logger.info("Travis test script, bot output:\r\n{}\r\nEnd of bot output".format("\r\n".join(output_as_list))) diff --git a/test/upgradestest_bot.py b/test/upgradestest_bot.py index 4d705a3f..35675a67 100644 --- a/test/upgradestest_bot.py +++ b/test/upgradestest_bot.py @@ -3,6 +3,7 @@ import sys from pathlib import Path +# pyre-ignore[6] sys.path.append(Path(__file__).parent) from loguru import logger @@ -179,6 +180,7 @@ async def on_start(self): await self.client.debug_kill_unit(self.units) async def on_step(self, iteration: int): + # pyre-ignore[16] map_center = self.game_info.map_center enemies = self.enemy_units | self.enemy_structures if enemies: