Core: some low-hanging fruit on the strict type check (#3416)

* Core: some low-hanging fruit on the strict type check

* bump pyright version

* bump pyright version

* bump pyright and remove file that's no longer easy
This commit is contained in:
Doug Hoskisson 2025-01-17 11:14:21 -08:00 committed by GitHub
parent 698d27aada
commit 23ea3c0efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 10 deletions

View File

@ -1,8 +1,20 @@
{ {
"include": [ "include": [
"type_check.py", "../BizHawkClient.py",
"../Patch.py",
"../test/general/test_groups.py",
"../test/general/test_helpers.py",
"../test/general/test_memory.py",
"../test/general/test_names.py",
"../test/multiworld/__init__.py",
"../test/multiworld/test_multiworlds.py",
"../test/netutils/__init__.py",
"../test/programs/__init__.py",
"../test/programs/test_multi_server.py",
"../test/utils/__init__.py",
"../test/webhost/test_descriptions.py",
"../worlds/AutoSNIClient.py", "../worlds/AutoSNIClient.py",
"../Patch.py" "type_check.py"
], ],
"exclude": [ "exclude": [

View File

@ -26,7 +26,7 @@ jobs:
- name: "Install dependencies" - name: "Install dependencies"
run: | run: |
python -m pip install --upgrade pip pyright==1.1.358 python -m pip install --upgrade pip pyright==1.1.377
python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes
- name: "pyright: strict check on specific files" - name: "pyright: strict check on specific files"

View File

@ -1,6 +1,8 @@
import unittest import unittest
from typing import Callable, Dict, Optional from typing import Callable, Dict, Optional
from typing_extensions import override
from BaseClasses import CollectionState, MultiWorld, Region from BaseClasses import CollectionState, MultiWorld, Region
@ -8,6 +10,7 @@ class TestHelpers(unittest.TestCase):
multiworld: MultiWorld multiworld: MultiWorld
player: int = 1 player: int = 1
@override
def setUp(self) -> None: def setUp(self) -> None:
self.multiworld = MultiWorld(self.player) self.multiworld = MultiWorld(self.player)
self.multiworld.game[self.player] = "helper_test_game" self.multiworld.game[self.player] = "helper_test_game"

View File

@ -5,7 +5,7 @@ from . import setup_solo_multiworld
class TestWorldMemory(unittest.TestCase): class TestWorldMemory(unittest.TestCase):
def test_leak(self): def test_leak(self) -> None:
"""Tests that worlds don't leak references to MultiWorld or themselves with default options.""" """Tests that worlds don't leak references to MultiWorld or themselves with default options."""
import gc import gc
import weakref import weakref

View File

@ -3,7 +3,7 @@ from worlds.AutoWorld import AutoWorldRegister
class TestNames(unittest.TestCase): class TestNames(unittest.TestCase):
def test_item_names_format(self): def test_item_names_format(self) -> None:
"""Item names must not be all numeric in order to differentiate between ID and name in !hint""" """Item names must not be all numeric in order to differentiate between ID and name in !hint"""
for gamename, world_type in AutoWorldRegister.world_types.items(): for gamename, world_type in AutoWorldRegister.world_types.items():
with self.subTest(game=gamename): with self.subTest(game=gamename):
@ -11,7 +11,7 @@ class TestNames(unittest.TestCase):
self.assertFalse(item_name.isnumeric(), self.assertFalse(item_name.isnumeric(),
f"Item name \"{item_name}\" is invalid. It must not be numeric.") f"Item name \"{item_name}\" is invalid. It must not be numeric.")
def test_location_name_format(self): def test_location_name_format(self) -> None:
"""Location names must not be all numeric in order to differentiate between ID and name in !hint_location""" """Location names must not be all numeric in order to differentiate between ID and name in !hint_location"""
for gamename, world_type in AutoWorldRegister.world_types.items(): for gamename, world_type in AutoWorldRegister.world_types.items():
with self.subTest(game=gamename): with self.subTest(game=gamename):