Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 20, 2024
1 parent 727a9ec commit dbc8554
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/mercury_engine_data_structures/common_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, value: int | str | tuple[int, int, int] | None = None):
elif isinstance(value, int):
value = struct.pack("<I", value)
value = struct.unpack("<HBB", value)

if value is None:
subcon = construct.Struct(major=construct.Int16ul, minor=construct.Int8ul, patch=construct.Int8ul)
else:
Expand All @@ -41,7 +41,7 @@ def __init__(self, value: int | str | tuple[int, int, int] | None = None):

def _decode(self, obj, context, path):
return f"{obj.major}.{obj.minor}.{obj.patch}"

def _encode(self, obj, context, path):
lst = [int(i) for i in obj.split(".")]
return {
Expand Down
4 changes: 2 additions & 2 deletions src/mercury_engine_data_structures/dread_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ def all_property_id_to_name() -> Dict[int, str]:
def all_files_ending_with(ext: str) -> list[str]:
if not ext.startswith("."):
ext = "." + ext
return [name for name in all_name_to_asset_id().keys() if name.endswith(ext)]

return [name for name in all_name_to_asset_id().keys() if name.endswith(ext)]
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/blsnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
from construct.core import (
Const,
Construct,
Hex,
IfThenElse,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector, VersionAdapter
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

Expand Down
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/bmdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
Construct,
Flag,
Float32l,
Int16ul,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector, VersionAdapter
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
Expand Down
14 changes: 7 additions & 7 deletions src/mercury_engine_data_structures/formats/bmsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

from mercury_engine_data_structures import common_types, type_lib
from mercury_engine_data_structures.common_types import (
Char,
CVector3D,
Float,
StrId,
make_dict,
make_vector,
VersionAdapter
Char,
CVector3D,
Float,
StrId,
VersionAdapter,
make_dict,
make_vector,
)
from mercury_engine_data_structures.construct_extensions.alignment import PrefixedAllowZeroLen
from mercury_engine_data_structures.construct_extensions.function_complex import ComplexIf, SwitchComplexKey
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Switch,
)

from mercury_engine_data_structures.common_types import Char, CVector3D, DictAdapter, Float, make_vector, VersionAdapter
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
Expand Down
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/bmsbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
Container,
Flag,
Float32l,
Hex,
Int32ul,
Rebuild,
Struct,
Terminated,
)

from mercury_engine_data_structures.common_types import CVector3D, StrId, make_vector, VersionAdapter
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

Expand Down
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/bmscc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Const,
Construct,
GreedyBytes,
Hex,
IfThenElse,
Int8ul,
Int16ul,
Expand All @@ -12,7 +11,7 @@
)

from mercury_engine_data_structures import game_check
from mercury_engine_data_structures.common_types import StrId, UInt, make_vector, VersionAdapter
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
Expand Down
3 changes: 1 addition & 2 deletions src/mercury_engine_data_structures/formats/bmsem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
Const,
Construct,
Float32l,
Hex,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector, VersionAdapter
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

Expand Down
4 changes: 1 addition & 3 deletions src/mercury_engine_data_structures/formats/bmses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
Const,
Construct,
Float32l,
Hex,
Int32sl,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector, VersionAdapter
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

Expand Down
9 changes: 1 addition & 8 deletions src/mercury_engine_data_structures/formats/bmsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
import construct
from construct import Const, Construct, Container, Flag, Float32l, Hex, Int32ul, Struct, Switch

from mercury_engine_data_structures.common_types import (
CVector3D,
Float,
StrId,
make_dict,
make_vector,
VersionAdapter
)
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
Expand Down
1 change: 0 additions & 1 deletion src/mercury_engine_data_structures/formats/bmslink.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from construct.core import (
Byte,
Const,
Hex,
Int32ul,
LazyBound,
PrefixedArray,
Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector, VersionAdapter
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

Expand Down
4 changes: 2 additions & 2 deletions src/mercury_engine_data_structures/formats/bmsmsd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import functools

import construct
from construct.core import Const, Construct, Enum, FlagsEnum, Float32l, Hex, Int32sl, Int32ul, Struct
from construct.core import Const, Construct, Enum, FlagsEnum, Float32l, Int32sl, Int32ul, Struct

from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, make_vector, VersionAdapter
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

Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmsnav.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from construct.core import Array, Byte, Const, Construct, Flag, Hex, Int32ul, PrefixedArray, Struct, Terminated

from mercury_engine_data_structures.common_types import CVector2D, CVector3D, Float, StrId, make_dict, VersionAdapter
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

Expand Down
2 changes: 1 addition & 1 deletion src/mercury_engine_data_structures/formats/bmssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)

from mercury_engine_data_structures import game_check
from mercury_engine_data_structures.common_types import CVector3D, StrId, make_vector, VersionAdapter
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
Expand Down
1 change: 0 additions & 1 deletion src/mercury_engine_data_structures/formats/bmtre.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Construct,
Container,
Flag,
Hex,
Int32sl,
Int32ul,
LazyBound,
Expand Down
4 changes: 1 addition & 3 deletions src/mercury_engine_data_structures/formats/bmtun.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
Const,
Construct,
Flag,
Hex,
Int32sl,
Int32ul,
Struct,
Switch,
)

from mercury_engine_data_structures.common_types import Char, CVector3D, Float, StrId, make_dict, VersionAdapter
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
Expand Down
1 change: 0 additions & 1 deletion src/mercury_engine_data_structures/formats/bsmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Container,
Enum,
Flag,
Hex,
Int32sl,
Int32ul,
PrefixedArray,
Expand Down
4 changes: 2 additions & 2 deletions src/mercury_engine_data_structures/samus_returns_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ def all_property_id_to_name() -> Dict[int, str]:
def all_files_ending_with(ext: str) -> list[str]:
if not ext.startswith("."):
ext = "." + ext
return [name for name in all_name_to_asset_id().keys() if name.endswith(ext)]

return [name for name in all_name_to_asset_id().keys() if name.endswith(ext)]
1 change: 0 additions & 1 deletion tests/formats/test_bcmdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from mercury_engine_data_structures import dread_data
from mercury_engine_data_structures.formats.bcmdl import Bcmdl


dread_bcmdl_expected_failure = [
'actors/characters/morphball/models/labase.bcmdl',
'actors/characters/morphball/models/ladamage.bcmdl',
Expand Down
1 change: 0 additions & 1 deletion tests/formats/test_bmbls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from mercury_engine_data_structures import dread_data
from mercury_engine_data_structures.formats.bmbls import Bmbls
from mercury_engine_data_structures.game_check import Game


@pytest.mark.parametrize("bmbls_path", dread_data.all_files_ending_with(".bmbls"))
Expand Down
3 changes: 1 addition & 2 deletions tests/formats/test_bmsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from mercury_engine_data_structures.formats import dread_types
from mercury_engine_data_structures.formats.bmsad import ActorDefFunc, Bmsad


expected_dread_failures = {
"actors/props/pf_mushr_fr/charclasses/pf_mushr_fr.bmsad",
}
Expand All @@ -33,7 +32,7 @@ def test_compare_dread_all(dread_file_tree, bmsad_path):
def test_compare_sr_all(samus_returns_tree, bmsad_path):
if not samus_returns_tree.does_asset_exists(bmsad_path):
return pytest.skip()

parse_build_compare_editor(Bmsad, samus_returns_tree, bmsad_path)


Expand Down
2 changes: 1 addition & 1 deletion tests/formats/test_bmsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def surface_bmsld(samus_returns_tree) -> Bmsld:
def test_bmsld(samus_returns_tree, bmsld_path):
if not samus_returns_tree.does_asset_exists(bmsld_path):
pytest.skip(f"{bmsld_path} does not exist!")

parse_build_compare_editor(Bmsld, samus_returns_tree, bmsld_path)

def test_all_actor_groups(surface_bmsld: Bmsld):
Expand Down
2 changes: 1 addition & 1 deletion tests/formats/test_bmsnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def test_dread_bmsnav(dread_file_tree, bmsnav_path):
def test_sr_bmsnav(samus_returns_tree, bmsnav_path):
if not samus_returns_tree.does_asset_exists(bmsnav_path):
pytest.skip(f"{bmsnav_path} does not exist!")

parse_build_compare_editor(Bmsnav, samus_returns_tree, bmsnav_path)
4 changes: 1 addition & 3 deletions tests/formats/test_bmssd.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import contextlib
import pytest
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import dread_data, samus_returns_data
from mercury_engine_data_structures.formats.bmssd import Bmssd
from mercury_engine_data_structures.game_check import Game


@pytest.mark.parametrize("bmssd_path", dread_data.all_files_ending_with(".bmssd"))
Expand All @@ -15,5 +13,5 @@ def test_compare_dread(dread_file_tree, bmssd_path):
def test_compare_msr(samus_returns_tree, bmssd_path):
if not samus_returns_tree.does_asset_exists(bmssd_path):
pytest.skip(f"{bmssd_path} does not exist!")

parse_build_compare_editor(Bmssd, samus_returns_tree, bmssd_path)
1 change: 0 additions & 1 deletion tests/formats/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from mercury_engine_data_structures import dread_data
from mercury_engine_data_structures.formats.gui_files import Bmscp, Bmssk, Bmsss
from mercury_engine_data_structures.game_check import Game


@pytest.mark.parametrize("bmscp_path", dread_data.all_files_ending_with(".bmscp"))
Expand Down
1 change: 0 additions & 1 deletion tests/formats/test_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from mercury_engine_data_structures.formats.pkg import Pkg
from mercury_engine_data_structures.game_check import Game


_EMPTY_DREAD_PKG = (b'\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

wrong_build_sr = [
Expand Down
3 changes: 1 addition & 2 deletions tests/formats/test_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import dread_data, samus_returns_data
from mercury_engine_data_structures.formats.txt import Txt, TXT
from mercury_engine_data_structures.game_check import Game
from mercury_engine_data_structures.formats.txt import Txt


@pytest.mark.parametrize("txt_path", dread_data.all_files_ending_with(".txt"))
Expand Down
5 changes: 1 addition & 4 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import typing
from pathlib import Path

import construct
import pytest
from construct.lib.containers import Container

from mercury_engine_data_structures.file_tree_editor import FileTreeEditor
from mercury_engine_data_structures.formats import BaseResource
Expand All @@ -19,7 +16,7 @@ def _parse_build_compare(module: typing.Type[BaseResource],
if print_data:
print(data)
encoded = construct_class.build(data, target_game=editor.target_game)

return raw, encoded, data

def parse_build_compare_editor(module: typing.Type[BaseResource],
Expand Down

0 comments on commit dbc8554

Please sign in to comment.