From d79c46d42872d911f3947ef785d901e99fe31b69 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 14 Oct 2024 10:42:38 +0300 Subject: [PATCH] Ruff fixes --- .../adapters/offset.py | 4 ++-- .../construct_extensions/strings.py | 10 +++++----- .../file_tree_editor.py | 15 +++++++++------ .../formats/__init__.py | 6 +++++- .../formats/bapd.py | 10 +++++++--- .../formats/bcmdl.py | 8 ++++++-- .../formats/bcskla.py | 2 +- .../formats/bctex.py | 2 +- .../formats/bgsnds.py | 10 +++++++--- .../formats/bldef.py | 10 +++++++--- .../formats/blsnd.py | 2 +- .../formats/blut.py | 8 ++++++-- .../formats/bmbls.py | 10 +++++++--- .../formats/bmdefs.py | 2 +- .../formats/bmmap.py | 11 +++++++---- .../formats/bmmdef.py | 8 ++++++-- .../formats/bmsad.py | 6 ++++-- .../formats/bmsas.py | 2 +- .../formats/bmsat.py | 10 +++++++--- .../formats/bmsbk.py | 7 +++++-- .../formats/bmscc.py | 2 +- .../formats/bmscu.py | 10 +++++++--- .../formats/bmsem.py | 8 ++++++-- .../formats/bmses.py | 7 +++++-- .../formats/bmsld.py | 10 +++++++--- .../formats/bmslgroup.py | 10 +++++++--- .../formats/bmslink.py | 8 ++++++-- .../formats/bmsmd.py | 7 +++++-- .../formats/bmsmsd.py | 7 +++++-- .../formats/bmsnav.py | 2 +- .../formats/bmssd.py | 2 +- .../formats/bmtre.py | 8 ++++++-- .../formats/bmtun.py | 7 +++++-- .../formats/bnvib.py | 7 +++++-- .../formats/bpsi.py | 2 +- .../formats/bptdat.py | 10 +++++++--- .../formats/brem.py | 10 +++++++--- .../formats/bres.py | 10 +++++++--- .../formats/brev.py | 10 +++++++--- .../formats/brfld.py | 14 +++++++++----- .../formats/brsa.py | 14 +++++++++----- .../formats/brspd.py | 10 +++++++--- .../formats/bsmat.py | 8 ++++++-- .../formats/btunda.py | 8 +++++--- .../formats/buct.py | 2 +- .../formats/gui_files.py | 10 +++++++--- src/mercury_engine_data_structures/formats/ini.py | 4 ++-- src/mercury_engine_data_structures/formats/lua.py | 2 +- src/mercury_engine_data_structures/formats/pkg.py | 2 +- src/mercury_engine_data_structures/formats/toc.py | 7 +++++-- src/mercury_engine_data_structures/formats/txt.py | 2 +- src/mercury_engine_data_structures/game_check.py | 6 ++++-- src/mercury_engine_data_structures/romfs.py | 13 ++++++------- tests/formats/test_bmsad.py | 6 +++++- tests/test_lib.py | 13 +++++++++---- tools/ghidra_export.py | 1 + tools/plot_simple_map.py | 5 ++++- tools/sr_export_rdv_database.py | 6 ++++-- 58 files changed, 278 insertions(+), 135 deletions(-) diff --git a/src/mercury_engine_data_structures/adapters/offset.py b/src/mercury_engine_data_structures/adapters/offset.py index 7581e733..2b1e9f3e 100644 --- a/src/mercury_engine_data_structures/adapters/offset.py +++ b/src/mercury_engine_data_structures/adapters/offset.py @@ -7,10 +7,10 @@ class OffsetAdapter(Adapter): # stores offsets as indices def _get_table(self, context): - raise NotImplementedError() + raise NotImplementedError def _get_table_length(self, context): - raise NotImplementedError() + raise NotImplementedError def _get_base_offset(self, context): return 0 diff --git a/src/mercury_engine_data_structures/construct_extensions/strings.py b/src/mercury_engine_data_structures/construct_extensions/strings.py index 1ec19d10..77088dca 100644 --- a/src/mercury_engine_data_structures/construct_extensions/strings.py +++ b/src/mercury_engine_data_structures/construct_extensions/strings.py @@ -52,7 +52,7 @@ def PaddedStringRobust(length, encoding): macro = StringEncodedRobust(FixedSized(length, NullStripped(GreedyBytes, pad=encodingunit(encoding))), encoding) def _emitfulltype(ksy, bitwise): - return dict(size=length, type="strz", encoding=encoding) + return {"size": length, "type": "strz", "encoding": encoding} macro._emitfulltype = _emitfulltype return macro @@ -88,8 +88,8 @@ def _emitparse(code): def _emitseq(ksy, bitwise): return [ - dict(id="lengthfield", type=lengthfield._compileprimitivetype(ksy, bitwise)), - dict(id="data", size="lengthfield", type="str", encoding=encoding), + {"id": "lengthfield", "type": lengthfield._compileprimitivetype(ksy, bitwise)}, + {"id": "data", "size": "lengthfield", "type": "str", "encoding": encoding}, ] macro._emitseq = _emitseq @@ -178,7 +178,7 @@ def read_util_term_{i}(io, this): macro._emitparse = _emitparse def _emitfulltype(ksy, bitwise): - return dict(type="strz", encoding=encoding) + return {"type": "strz", "encoding": encoding} macro._emitfulltype = _emitfulltype @@ -212,7 +212,7 @@ def GreedyStringRobust(encoding): macro = StringEncodedRobust(GreedyBytes, encoding) def _emitfulltype(ksy, bitwise): - return dict(size_eos=True, type="str", encoding=encoding) + return {"size_eos": True, "type": "str", "encoding": encoding} macro._emitfulltype = _emitfulltype return macro diff --git a/src/mercury_engine_data_structures/file_tree_editor.py b/src/mercury_engine_data_structures/file_tree_editor.py index 18f211aa..1c6781c4 100644 --- a/src/mercury_engine_data_structures/file_tree_editor.py +++ b/src/mercury_engine_data_structures/file_tree_editor.py @@ -6,17 +6,20 @@ import logging import os.path import typing -from collections.abc import Iterator -from pathlib import Path - -import construct from mercury_engine_data_structures import dread_data, formats, samus_returns_data +from mercury_engine_data_structures.base_resource import AssetId, BaseResource, NameOrAssetId, resolve_asset_id from mercury_engine_data_structures.formats import Toc -from mercury_engine_data_structures.formats.base_resource import AssetId, BaseResource, NameOrAssetId, resolve_asset_id from mercury_engine_data_structures.formats.pkg import Pkg from mercury_engine_data_structures.game_check import Game -from mercury_engine_data_structures.romfs import RomFs + +if typing.TYPE_CHECKING: + from collections.abc import Iterator + from pathlib import Path + + import construct + + from mercury_engine_data_structures.romfs import RomFs _T = typing.TypeVar("_T", bound=BaseResource) logger = logging.getLogger(__name__) diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index ece22d03..37ba59b7 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -1,7 +1,8 @@ from __future__ import annotations +from typing import TYPE_CHECKING + from mercury_engine_data_structures.formats.bapd import Bapd -from mercury_engine_data_structures.formats.base_resource import AssetType, BaseResource from mercury_engine_data_structures.formats.bcmdl import Bcmdl from mercury_engine_data_structures.formats.bcskla import Bcskla from mercury_engine_data_structures.formats.bctex import Bctex @@ -49,6 +50,9 @@ from mercury_engine_data_structures.formats.toc import Toc from mercury_engine_data_structures.formats.txt import Txt +if TYPE_CHECKING: + from mercury_engine_data_structures.base_resource import AssetType, BaseResource + ALL_FORMATS = { "PKG": Pkg, "BAPD": Bapd, diff --git a/src/mercury_engine_data_structures/formats/bapd.py b/src/mercury_engine_data_structures/formats/bapd.py index 94004a97..f329e2b3 100644 --- a/src/mercury_engine_data_structures/formats/bapd.py +++ b/src/mercury_engine_data_structures/formats/bapd.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING -from mercury_engine_data_structures.formats.base_resource import BaseResource +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats.standard_format import game_model -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game BAPD = game_model("sound::CAudioPresets", "2.3.2") diff --git a/src/mercury_engine_data_structures/formats/bcmdl.py b/src/mercury_engine_data_structures/formats/bcmdl.py index 31c1859a..2f5b6298 100644 --- a/src/mercury_engine_data_structures/formats/bcmdl.py +++ b/src/mercury_engine_data_structures/formats/bcmdl.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import construct from construct.core import ( Array, @@ -26,9 +28,11 @@ stream_seek, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Float, StrId -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game # Partial implementation to generate material variants # Based off Joschuka's MMDL implementation in Noesis diff --git a/src/mercury_engine_data_structures/formats/bcskla.py b/src/mercury_engine_data_structures/formats/bcskla.py index 1decc7ef..fedf6bf9 100644 --- a/src/mercury_engine_data_structures/formats/bcskla.py +++ b/src/mercury_engine_data_structures/formats/bcskla.py @@ -22,9 +22,9 @@ this, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Float, VersionAdapter from mercury_engine_data_structures.construct_extensions.alignment import AlignTo -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.property_enum import PropertyEnumDoubleUnsafe from mercury_engine_data_structures.game_check import Game diff --git a/src/mercury_engine_data_structures/formats/bctex.py b/src/mercury_engine_data_structures/formats/bctex.py index 96712899..483b1a33 100644 --- a/src/mercury_engine_data_structures/formats/bctex.py +++ b/src/mercury_engine_data_structures/formats/bctex.py @@ -5,8 +5,8 @@ import construct from construct.core import Error +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, UInt -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game BlockType = construct.Enum( diff --git a/src/mercury_engine_data_structures/formats/bgsnds.py b/src/mercury_engine_data_structures/formats/bgsnds.py index fab13ab3..e3c9efa9 100644 --- a/src/mercury_engine_data_structures/formats/bgsnds.py +++ b/src/mercury_engine_data_structures/formats/bgsnds.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct + + from mercury_engine_data_structures.game_check import Game class Bgsnds(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/bldef.py b/src/mercury_engine_data_structures/formats/bldef.py index 29a17e9a..8d0ae0f2 100644 --- a/src/mercury_engine_data_structures/formats/bldef.py +++ b/src/mercury_engine_data_structures/formats/bldef.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct, Container +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct, Container + + from mercury_engine_data_structures.game_check import Game class Bldef(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/blsnd.py b/src/mercury_engine_data_structures/formats/blsnd.py index 6c816ff5..8a2b22eb 100644 --- a/src/mercury_engine_data_structures/formats/blsnd.py +++ b/src/mercury_engine_data_structures/formats/blsnd.py @@ -11,8 +11,8 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game, current_game_at_most BLSND = Struct( diff --git a/src/mercury_engine_data_structures/formats/blut.py b/src/mercury_engine_data_structures/formats/blut.py index 94f48c0f..8242d319 100644 --- a/src/mercury_engine_data_structures/formats/blut.py +++ b/src/mercury_engine_data_structures/formats/blut.py @@ -1,10 +1,14 @@ from __future__ import annotations +from typing import TYPE_CHECKING + from construct.core import Const, Construct, Int32ul, PrefixedArray, Struct +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Float, VersionAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game BLUT = Struct(magic=Const(b"LUT"), ver=VersionAdapter("1.1.0"), data=PrefixedArray(Int32ul, Float)) diff --git a/src/mercury_engine_data_structures/formats/bmbls.py b/src/mercury_engine_data_structures/formats/bmbls.py index 460da8bd..bf3f9ebf 100644 --- a/src/mercury_engine_data_structures/formats/bmbls.py +++ b/src/mercury_engine_data_structures/formats/bmbls.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game BMBLS = standard_format.create("base::animation::CBlendSpaceResource", "1.2.2") diff --git a/src/mercury_engine_data_structures/formats/bmdefs.py b/src/mercury_engine_data_structures/formats/bmdefs.py index 3b079264..5f13ad57 100644 --- a/src/mercury_engine_data_structures/formats/bmdefs.py +++ b/src/mercury_engine_data_structures/formats/bmdefs.py @@ -10,9 +10,9 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game EnemyStruct = Struct( diff --git a/src/mercury_engine_data_structures/formats/bmmap.py b/src/mercury_engine_data_structures/formats/bmmap.py index e1207bb7..9039cfe7 100644 --- a/src/mercury_engine_data_structures/formats/bmmap.py +++ b/src/mercury_engine_data_structures/formats/bmmap.py @@ -1,12 +1,15 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING -from construct import Construct, Container - +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct, Container + + from mercury_engine_data_structures.game_check import Game BMMAP = standard_format.create("CMinimapData", "1.0.2") diff --git a/src/mercury_engine_data_structures/formats/bmmdef.py b/src/mercury_engine_data_structures/formats/bmmdef.py index 191bddec..67c4b753 100644 --- a/src/mercury_engine_data_structures/formats/bmmdef.py +++ b/src/mercury_engine_data_structures/formats/bmmdef.py @@ -1,10 +1,14 @@ from __future__ import annotations +from typing import TYPE_CHECKING + from construct import Construct, Container +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game BMMDEF = standard_format.create("CMinimapDef", "1.0.2") diff --git a/src/mercury_engine_data_structures/formats/bmsad.py b/src/mercury_engine_data_structures/formats/bmsad.py index d3e25602..29fa7098 100644 --- a/src/mercury_engine_data_structures/formats/bmsad.py +++ b/src/mercury_engine_data_structures/formats/bmsad.py @@ -3,7 +3,6 @@ import copy import functools import typing -from collections.abc import Sequence import construct from construct.core import ( @@ -25,6 +24,7 @@ from construct.lib.containers import Container, ListContainer from mercury_engine_data_structures import common_types, type_lib +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import ( Char, CVector3D, @@ -37,12 +37,14 @@ from mercury_engine_data_structures.construct_extensions.alignment import PrefixedAllowZeroLen from mercury_engine_data_structures.construct_extensions.function_complex import ComplexIf, SwitchComplexKey from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.bmsas import BMSAS_SR, Bmsas from mercury_engine_data_structures.formats.property_enum import PropertyEnum from mercury_engine_data_structures.game_check import Game, GameSpecificStruct from mercury_engine_data_structures.type_lib import get_type_lib_dread, get_type_lib_for_game +if typing.TYPE_CHECKING: + from collections.abc import Sequence + # Functions FunctionArgument = Struct( "type" / Char, diff --git a/src/mercury_engine_data_structures/formats/bmsas.py b/src/mercury_engine_data_structures/formats/bmsas.py index c1b0b9ee..0a39d087 100644 --- a/src/mercury_engine_data_structures/formats/bmsas.py +++ b/src/mercury_engine_data_structures/formats/bmsas.py @@ -20,10 +20,10 @@ Switch, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Char, CVector3D, DictAdapter, Float, VersionAdapter, make_vector from mercury_engine_data_structures.common_types import StrId as StrIdSR from mercury_engine_data_structures.construct_extensions.strings import PascalStringRobust -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.property_enum import PropertyEnum, PropertyEnumDoubleUnsafe from mercury_engine_data_structures.game_check import Game, GameSpecificStruct diff --git a/src/mercury_engine_data_structures/formats/bmsat.py b/src/mercury_engine_data_structures/formats/bmsat.py index 7d0e696a..76528335 100644 --- a/src/mercury_engine_data_structures/formats/bmsat.py +++ b/src/mercury_engine_data_structures/formats/bmsat.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct + + from mercury_engine_data_structures.game_check import Game class Bmsat(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/bmsbk.py b/src/mercury_engine_data_structures/formats/bmsbk.py index 9928d685..03fc0037 100644 --- a/src/mercury_engine_data_structures/formats/bmsbk.py +++ b/src/mercury_engine_data_structures/formats/bmsbk.py @@ -1,6 +1,7 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING from construct import ( Array, @@ -15,9 +16,11 @@ Terminated, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import CVector3D, StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game Block = Struct( "pos" / CVector3D, diff --git a/src/mercury_engine_data_structures/formats/bmscc.py b/src/mercury_engine_data_structures/formats/bmscc.py index 625751fa..aaee9a30 100644 --- a/src/mercury_engine_data_structures/formats/bmscc.py +++ b/src/mercury_engine_data_structures/formats/bmscc.py @@ -13,9 +13,9 @@ ) from mercury_engine_data_structures import game_check +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.collision import collision_formats from mercury_engine_data_structures.game_check import Game diff --git a/src/mercury_engine_data_structures/formats/bmscu.py b/src/mercury_engine_data_structures/formats/bmscu.py index d9875a84..ec2cd619 100644 --- a/src/mercury_engine_data_structures/formats/bmscu.py +++ b/src/mercury_engine_data_structures/formats/bmscu.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct + + from mercury_engine_data_structures.game_check import Game BMSCU = standard_format.create("CCutSceneDef", "8.3.2") diff --git a/src/mercury_engine_data_structures/formats/bmsem.py b/src/mercury_engine_data_structures/formats/bmsem.py index 7e9b269e..5211d6ef 100644 --- a/src/mercury_engine_data_structures/formats/bmsem.py +++ b/src/mercury_engine_data_structures/formats/bmsem.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import construct from construct import ( Const, @@ -9,9 +11,11 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game BMSEM = Struct( _magic=Const(b"MSEM"), diff --git a/src/mercury_engine_data_structures/formats/bmses.py b/src/mercury_engine_data_structures/formats/bmses.py index bb6c7222..39669efd 100644 --- a/src/mercury_engine_data_structures/formats/bmses.py +++ b/src/mercury_engine_data_structures/formats/bmses.py @@ -1,6 +1,7 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING import construct from construct.core import ( @@ -11,9 +12,11 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game BMSES = Struct( "_magic" / Const(b"MSES"), diff --git a/src/mercury_engine_data_structures/formats/bmsld.py b/src/mercury_engine_data_structures/formats/bmsld.py index b83e4cd4..7c7c3874 100644 --- a/src/mercury_engine_data_structures/formats/bmsld.py +++ b/src/mercury_engine_data_structures/formats/bmsld.py @@ -1,18 +1,22 @@ from __future__ import annotations import logging -from collections.abc import Iterator +from typing import TYPE_CHECKING import construct from construct import Const, Construct, Container, Flag, Float32l, Hex, Int32ul, Struct, Switch +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import CVector3D, Float, StrId, VersionAdapter, make_dict, make_vector from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage from mercury_engine_data_structures.construct_extensions.strings import StaticPaddedString from mercury_engine_data_structures.crc import crc32 -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.collision import collision_formats -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from collections.abc import Iterator + + from mercury_engine_data_structures.game_check import Game logger = logging.getLogger(__name__) diff --git a/src/mercury_engine_data_structures/formats/bmslgroup.py b/src/mercury_engine_data_structures/formats/bmslgroup.py index 40a93a7b..ff31b675 100644 --- a/src/mercury_engine_data_structures/formats/bmslgroup.py +++ b/src/mercury_engine_data_structures/formats/bmslgroup.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game BMSLGROUP = standard_format.create("navmesh::CDynamicSmartLinkGroup", "1.0.2") diff --git a/src/mercury_engine_data_structures/formats/bmslink.py b/src/mercury_engine_data_structures/formats/bmslink.py index b450a286..2b06c610 100644 --- a/src/mercury_engine_data_structures/formats/bmslink.py +++ b/src/mercury_engine_data_structures/formats/bmslink.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import construct from construct import Construct from construct.core import ( @@ -11,9 +13,11 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Float, StrId, VersionAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game UnkStruct = Struct( unk1=StrId, diff --git a/src/mercury_engine_data_structures/formats/bmsmd.py b/src/mercury_engine_data_structures/formats/bmsmd.py index 6a49e91a..d7498271 100644 --- a/src/mercury_engine_data_structures/formats/bmsmd.py +++ b/src/mercury_engine_data_structures/formats/bmsmd.py @@ -1,6 +1,7 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING from construct.core import ( Array, @@ -13,9 +14,11 @@ Struct, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game BMSMD = Struct( "_magic" / Const(b"MSMD"), diff --git a/src/mercury_engine_data_structures/formats/bmsmsd.py b/src/mercury_engine_data_structures/formats/bmsmsd.py index 5945dd38..179cf222 100644 --- a/src/mercury_engine_data_structures/formats/bmsmsd.py +++ b/src/mercury_engine_data_structures/formats/bmsmsd.py @@ -1,13 +1,16 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING import construct from construct.core import Const, Construct, Enum, FlagsEnum, Float32l, Int32sl, Int32ul, Struct +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, VersionAdapter, make_vector -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game TileBorders = FlagsEnum( Int32sl, diff --git a/src/mercury_engine_data_structures/formats/bmsnav.py b/src/mercury_engine_data_structures/formats/bmsnav.py index d10ee898..f23fa15a 100644 --- a/src/mercury_engine_data_structures/formats/bmsnav.py +++ b/src/mercury_engine_data_structures/formats/bmsnav.py @@ -2,8 +2,8 @@ from construct.core import Array, Byte, Const, Construct, Flag, Hex, Int32ul, PrefixedArray, Struct, Terminated +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import CVector2D, CVector3D, Float, StrId, VersionAdapter, make_dict -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game ### A ton of barely-understood structs :] diff --git a/src/mercury_engine_data_structures/formats/bmssd.py b/src/mercury_engine_data_structures/formats/bmssd.py index 4cedcd6a..14712b9f 100644 --- a/src/mercury_engine_data_structures/formats/bmssd.py +++ b/src/mercury_engine_data_structures/formats/bmssd.py @@ -12,9 +12,9 @@ ) from mercury_engine_data_structures import game_check +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import CVector3D, StrId, VersionAdapter, make_vector from mercury_engine_data_structures.construct_extensions.strings import StaticPaddedString -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game BMSSD = Struct( diff --git a/src/mercury_engine_data_structures/formats/bmtre.py b/src/mercury_engine_data_structures/formats/bmtre.py index edc80cfd..6f5c15ee 100644 --- a/src/mercury_engine_data_structures/formats/bmtre.py +++ b/src/mercury_engine_data_structures/formats/bmtre.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import construct from construct.core import ( Array, @@ -15,10 +17,12 @@ Switch, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Float, StrId, VersionAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.formats.property_enum import PropertyEnum -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game ArgumentCases = { "b": Flag, diff --git a/src/mercury_engine_data_structures/formats/bmtun.py b/src/mercury_engine_data_structures/formats/bmtun.py index ae3f2ca9..4dc1912b 100644 --- a/src/mercury_engine_data_structures/formats/bmtun.py +++ b/src/mercury_engine_data_structures/formats/bmtun.py @@ -1,6 +1,7 @@ from __future__ import annotations import functools +from typing import TYPE_CHECKING import construct from construct.core import ( @@ -12,10 +13,12 @@ Switch, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Char, CVector3D, Float, StrId, VersionAdapter, make_dict from mercury_engine_data_structures.construct_extensions.misc import ErrorWithMessage -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game # Functions TunableParam = Struct( diff --git a/src/mercury_engine_data_structures/formats/bnvib.py b/src/mercury_engine_data_structures/formats/bnvib.py index 32ab0e16..ff238437 100644 --- a/src/mercury_engine_data_structures/formats/bnvib.py +++ b/src/mercury_engine_data_structures/formats/bnvib.py @@ -1,6 +1,7 @@ from __future__ import annotations from enum import Enum +from typing import TYPE_CHECKING import construct from construct.core import ( @@ -15,8 +16,10 @@ ) from mercury_engine_data_structures.adapters.enum_adapter import EnumAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game +from mercury_engine_data_structures.base_resource import BaseResource + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game # Standard switch format. https://switchbrew.org/wiki/BNVIB#Normal_Vibration diff --git a/src/mercury_engine_data_structures/formats/bpsi.py b/src/mercury_engine_data_structures/formats/bpsi.py index c3f179da..4bca60ed 100644 --- a/src/mercury_engine_data_structures/formats/bpsi.py +++ b/src/mercury_engine_data_structures/formats/bpsi.py @@ -3,9 +3,9 @@ from construct.core import Const, Construct, IfThenElse, Int32ul, PrefixedArray, Struct, Terminated from mercury_engine_data_structures import game_check +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import VersionAdapter from mercury_engine_data_structures.construct_extensions.strings import PascalStringRobust -from mercury_engine_data_structures.formats.base_resource import BaseResource BPSI = Struct( _magic=Const(b"MPSI"), diff --git a/src/mercury_engine_data_structures/formats/bptdat.py b/src/mercury_engine_data_structures/formats/bptdat.py index 0d56c7a8..bbd8762d 100644 --- a/src/mercury_engine_data_structures/formats/bptdat.py +++ b/src/mercury_engine_data_structures/formats/bptdat.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game BPTDAT = standard_format.create("CPlaythrough", "1.0.2") BPTDEF = standard_format.create("CPlaythroughDef", "1.0.2") diff --git a/src/mercury_engine_data_structures/formats/brem.py b/src/mercury_engine_data_structures/formats/brem.py index c9769925..b7f879e0 100644 --- a/src/mercury_engine_data_structures/formats/brem.py +++ b/src/mercury_engine_data_structures/formats/brem.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game class Brem(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/bres.py b/src/mercury_engine_data_structures/formats/bres.py index 88b7b7c1..d65ae418 100644 --- a/src/mercury_engine_data_structures/formats/bres.py +++ b/src/mercury_engine_data_structures/formats/bres.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game class Bres(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/brev.py b/src/mercury_engine_data_structures/formats/brev.py index 73aa94bb..c3ad86c2 100644 --- a/src/mercury_engine_data_structures/formats/brev.py +++ b/src/mercury_engine_data_structures/formats/brev.py @@ -1,10 +1,14 @@ from __future__ import annotations -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + import construct + + from mercury_engine_data_structures.game_check import Game class Brev(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/brfld.py b/src/mercury_engine_data_structures/formats/brfld.py index 8826836e..5172bef8 100644 --- a/src/mercury_engine_data_structures/formats/brfld.py +++ b/src/mercury_engine_data_structures/formats/brfld.py @@ -2,13 +2,17 @@ import functools import logging -from collections.abc import Iterator - -import construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from collections.abc import Iterator + + import construct + + from mercury_engine_data_structures.game_check import Game logger = logging.getLogger(__name__) diff --git a/src/mercury_engine_data_structures/formats/brsa.py b/src/mercury_engine_data_structures/formats/brsa.py index d67715d1..660b8d55 100644 --- a/src/mercury_engine_data_structures/formats/brsa.py +++ b/src/mercury_engine_data_structures/formats/brsa.py @@ -1,13 +1,17 @@ from __future__ import annotations import functools -from collections.abc import Iterator - -from construct import Construct, Container +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from collections.abc import Iterator + + from construct import Construct, Container + + from mercury_engine_data_structures.game_check import Game class Brsa(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/brspd.py b/src/mercury_engine_data_structures/formats/brspd.py index 88af1e3e..026c78b4 100644 --- a/src/mercury_engine_data_structures/formats/brspd.py +++ b/src/mercury_engine_data_structures/formats/brspd.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct + + from mercury_engine_data_structures.game_check import Game class Brspd(BaseResource): diff --git a/src/mercury_engine_data_structures/formats/bsmat.py b/src/mercury_engine_data_structures/formats/bsmat.py index 69a21de4..c470443c 100644 --- a/src/mercury_engine_data_structures/formats/bsmat.py +++ b/src/mercury_engine_data_structures/formats/bsmat.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import construct from construct.core import ( Array, @@ -16,9 +18,11 @@ Switch, ) +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import Char, Float, StrId, VersionAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game # these seem to be using Unity ShaderLab, or at least the gist I borrowed this from uses similar teminology # source for most binary info: https://gist.github.com/KillzXGaming/9817455559544cb3613f99184aa3ed68 diff --git a/src/mercury_engine_data_structures/formats/btunda.py b/src/mercury_engine_data_structures/formats/btunda.py index 60e23324..c8133228 100644 --- a/src/mercury_engine_data_structures/formats/btunda.py +++ b/src/mercury_engine_data_structures/formats/btunda.py @@ -1,15 +1,17 @@ from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any import construct from construct import Struct from mercury_engine_data_structures import type_lib +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import VersionAdapter -from mercury_engine_data_structures.formats import BaseResource from mercury_engine_data_structures.formats.property_enum import PropertyEnum -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from mercury_engine_data_structures.game_check import Game VALID_BTUNDA_VERSIONS = [ "119.0.2", # 1.0.0 diff --git a/src/mercury_engine_data_structures/formats/buct.py b/src/mercury_engine_data_structures/formats/buct.py index 407cb13e..f4b7cd77 100644 --- a/src/mercury_engine_data_structures/formats/buct.py +++ b/src/mercury_engine_data_structures/formats/buct.py @@ -15,8 +15,8 @@ ) from mercury_engine_data_structures import game_check +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import VersionAdapter -from mercury_engine_data_structures.formats.base_resource import BaseResource BUCT = Struct( _magic=Const(b"MUCT"), diff --git a/src/mercury_engine_data_structures/formats/gui_files.py b/src/mercury_engine_data_structures/formats/gui_files.py index 6bbeaebf..aec3f88c 100644 --- a/src/mercury_engine_data_structures/formats/gui_files.py +++ b/src/mercury_engine_data_structures/formats/gui_files.py @@ -1,10 +1,14 @@ from __future__ import annotations -from construct import Construct, Container +from typing import TYPE_CHECKING +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.formats import standard_format -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game + +if TYPE_CHECKING: + from construct import Construct, Container + + from mercury_engine_data_structures.game_check import Game BMSCP = standard_format.create("GUI::CDisplayObjectContainer", "1.2.2", explicit_root=True) BMSSH = standard_format.create("GUI::CGUIManager::ShapeContainer", "1.2.2", explicit_root=True) diff --git a/src/mercury_engine_data_structures/formats/ini.py b/src/mercury_engine_data_structures/formats/ini.py index a81b8c6c..4c5533e6 100644 --- a/src/mercury_engine_data_structures/formats/ini.py +++ b/src/mercury_engine_data_structures/formats/ini.py @@ -7,11 +7,11 @@ from construct import Construct, Container, GreedyString, Struct -from mercury_engine_data_structures.formats.base_resource import BaseResource -from mercury_engine_data_structures.game_check import Game +from mercury_engine_data_structures.base_resource import BaseResource if typing.TYPE_CHECKING: from mercury_engine_data_structures.file_tree_editor import FileTreeEditor + from mercury_engine_data_structures.game_check import Game INI = Struct("text" / GreedyString("utf-8")) diff --git a/src/mercury_engine_data_structures/formats/lua.py b/src/mercury_engine_data_structures/formats/lua.py index 2a6abbe8..7603d199 100644 --- a/src/mercury_engine_data_structures/formats/lua.py +++ b/src/mercury_engine_data_structures/formats/lua.py @@ -4,8 +4,8 @@ import construct +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import StrId -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game if typing.TYPE_CHECKING: diff --git a/src/mercury_engine_data_structures/formats/pkg.py b/src/mercury_engine_data_structures/formats/pkg.py index c861e2a2..9635d09c 100644 --- a/src/mercury_engine_data_structures/formats/pkg.py +++ b/src/mercury_engine_data_structures/formats/pkg.py @@ -15,8 +15,8 @@ ) from mercury_engine_data_structures import dread_data, samus_returns_data +from mercury_engine_data_structures.base_resource import AssetId, BaseResource, NameOrAssetId, resolve_asset_id from mercury_engine_data_structures.construct_extensions.alignment import AlignTo -from mercury_engine_data_structures.formats.base_resource import AssetId, BaseResource, NameOrAssetId, resolve_asset_id from mercury_engine_data_structures.game_check import Game diff --git a/src/mercury_engine_data_structures/formats/toc.py b/src/mercury_engine_data_structures/formats/toc.py index d8484bea..0d40311c 100644 --- a/src/mercury_engine_data_structures/formats/toc.py +++ b/src/mercury_engine_data_structures/formats/toc.py @@ -1,14 +1,17 @@ from __future__ import annotations import functools -from collections.abc import Iterator +from typing import TYPE_CHECKING import construct from mercury_engine_data_structures import common_types -from mercury_engine_data_structures.formats.base_resource import BaseResource, NameOrAssetId, resolve_asset_id +from mercury_engine_data_structures.base_resource import BaseResource, NameOrAssetId, resolve_asset_id from mercury_engine_data_structures.game_check import Game +if TYPE_CHECKING: + from collections.abc import Iterator + TOC_SR = construct.Struct( files=common_types.make_dict( value=construct.Int32ul, diff --git a/src/mercury_engine_data_structures/formats/txt.py b/src/mercury_engine_data_structures/formats/txt.py index 644e99ba..72e9848a 100644 --- a/src/mercury_engine_data_structures/formats/txt.py +++ b/src/mercury_engine_data_structures/formats/txt.py @@ -5,9 +5,9 @@ import construct from construct.core import Const, Construct, GreedyRange, Struct +from mercury_engine_data_structures.base_resource import BaseResource from mercury_engine_data_structures.common_types import DictAdapter, DictElement, VersionAdapter from mercury_engine_data_structures.construct_extensions.strings import CStringRobust -from mercury_engine_data_structures.formats.base_resource import BaseResource from mercury_engine_data_structures.game_check import Game, is_sr_or_else _string_range = GreedyRange(DictElement(CStringRobust("utf-16-le"))) diff --git a/src/mercury_engine_data_structures/game_check.py b/src/mercury_engine_data_structures/game_check.py index 4b376acb..a6948a61 100644 --- a/src/mercury_engine_data_structures/game_check.py +++ b/src/mercury_engine_data_structures/game_check.py @@ -4,16 +4,18 @@ from __future__ import annotations -from collections.abc import Callable from enum import Enum from functools import cached_property -from typing import Any +from typing import TYPE_CHECKING, Any import construct from construct.core import IfThenElse from mercury_engine_data_structures import crc +if TYPE_CHECKING: + from collections.abc import Callable + class Game(Enum): SAMUS_RETURNS = 10 diff --git a/src/mercury_engine_data_structures/romfs.py b/src/mercury_engine_data_structures/romfs.py index 5252f15c..af102ce9 100644 --- a/src/mercury_engine_data_structures/romfs.py +++ b/src/mercury_engine_data_structures/romfs.py @@ -1,10 +1,13 @@ from __future__ import annotations -import io from abc import ABC, abstractmethod -from collections.abc import Iterator from contextlib import contextmanager -from pathlib import Path +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + import io + from collections.abc import Iterator + from pathlib import Path class RomFs(ABC): @@ -15,7 +18,6 @@ def get_pkg_stream(self, file_path: str) -> Iterator[io.BufferedIOBase]: :param file_path: File path to the pkg file """ - pass @abstractmethod def read_file_with_entry(self, file_path: str, entry) -> bytes: @@ -24,7 +26,6 @@ def read_file_with_entry(self, file_path: str, entry) -> bytes: :param file_path: File path to the pkg file :param entry: An entry object containing the end_offset and start_offset within the pkg """ - pass @abstractmethod def get_file(self, file_path: str) -> bytes: @@ -32,12 +33,10 @@ def get_file(self, file_path: str) -> bytes: :param file_path: Path to the file """ - pass @abstractmethod def all_files(self) -> Iterator[str]: """Returns an Iterator for all files within the RomFS""" - pass class ExtractedRomFs(RomFs): diff --git a/tests/formats/test_bmsad.py b/tests/formats/test_bmsad.py index a9a115df..1c9887ab 100644 --- a/tests/formats/test_bmsad.py +++ b/tests/formats/test_bmsad.py @@ -1,13 +1,17 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest from tests.test_lib import parse_build_compare_editor, parse_build_compare_editor_parsed from mercury_engine_data_structures import dread_data, samus_returns_data -from mercury_engine_data_structures.file_tree_editor import FileTreeEditor from mercury_engine_data_structures.formats import dread_types from mercury_engine_data_structures.formats.bmsad import ActorDefFunc, Bmsad +if TYPE_CHECKING: + from mercury_engine_data_structures.file_tree_editor import FileTreeEditor + dread_must_reencode = ["actors/props/pf_mushr_fr/charclasses/pf_mushr_fr.bmsad"] expected_sr_failures = set() diff --git a/tests/test_lib.py b/tests/test_lib.py index fe7c671a..4307ca9a 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -1,14 +1,19 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING -import construct import pytest -from mercury_engine_data_structures.file_tree_editor import FileTreeEditor -from mercury_engine_data_structures.formats import BaseResource from mercury_engine_data_structures.game_check import Game, GameSpecificStruct +if TYPE_CHECKING: + from pathlib import Path + + import construct + + from mercury_engine_data_structures.base_resource import BaseResource + from mercury_engine_data_structures.file_tree_editor import FileTreeEditor + def parse_and_build_compare(module, game: Game, file_path: Path, print_data=False, save_file=None): if not file_path.is_file(): diff --git a/tools/ghidra_export.py b/tools/ghidra_export.py index 5e5b8b0a..679db058 100644 --- a/tools/ghidra_export.py +++ b/tools/ghidra_export.py @@ -23,6 +23,7 @@ from mercury_engine_data_structures.type_lib import PrimitiveKind, TypeKind # ruff: noqa: PLW0603 +# ruff: noqa: PLW2901 # New JSON Format known_types_to_construct = { diff --git a/tools/plot_simple_map.py b/tools/plot_simple_map.py index 2212e7ed..089d0c05 100644 --- a/tools/plot_simple_map.py +++ b/tools/plot_simple_map.py @@ -15,7 +15,6 @@ import typing from pathlib import Path -import construct import numpy from shapely.geometry import Point from shapely.geometry.polygon import Polygon @@ -26,7 +25,11 @@ from mercury_engine_data_structures.game_check import Game from mercury_engine_data_structures.romfs import ExtractedRomFs +if typing.TYPE_CHECKING: + import construct + # ruff: noqa: PLW0603 +# ruff: noqa: PLW2901 world_names = { "maps/levels/c10_samus/s010_cave/s010_cave.brfld": "Artaria", diff --git a/tools/sr_export_rdv_database.py b/tools/sr_export_rdv_database.py index fc1bae6a..6dc592c6 100644 --- a/tools/sr_export_rdv_database.py +++ b/tools/sr_export_rdv_database.py @@ -18,7 +18,6 @@ import typing from pathlib import Path -import construct import numpy from matplotlib.patches import Polygon as mtPolygon from shapely.geometry import Point @@ -30,6 +29,9 @@ from mercury_engine_data_structures.game_check import Game from mercury_engine_data_structures.romfs import ExtractedRomFs +if typing.TYPE_CHECKING: + import construct + # ruff: noqa: PLW0603 world_names = { @@ -726,7 +728,7 @@ def add_node(target_area: str, node_def: NodeDefinition): raise ValueError("What kind of actor is this?!") handles_by_label = {} - handles_by_label = {key: value for key, value in sorted(handles_by_label.items(), key=lambda it: it[0])} + handles_by_label = dict(sorted(handles_by_label.items(), key=lambda it: it[0])) plt.legend(handles_by_label.values(), handles_by_label.keys()) plt.plot()