Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Sep 17, 2023
1 parent fe84883 commit f45c27b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 6 additions & 2 deletions amulet/api/wrapper/format_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ def _get_raw_player_data(self, player_id: str) -> Any:

# This can get removed when we know that nothing is blindly calling __init__
from contextvars import ContextVar

_blind_call_init = ContextVar("_blind_call_init", default=True)


Expand All @@ -750,7 +751,9 @@ def __init__(self, path: str):
:param path: The file path to the serialised data.
"""
if _blind_call_init.get():
raise RuntimeError("You cannot call FormatWrapper.__init__ directly. You must use one of the constructor classmethod.")
raise RuntimeError(
"You cannot call FormatWrapper.__init__ directly. You must use one of the constructor classmethod."
)
super().__init__()
self._path = path

Expand Down Expand Up @@ -786,7 +789,8 @@ def create_and_open(
self = cls(path)
_blind_call_init.reset(token)
if (
platform not in self.valid_formats() or len(self.valid_formats()[platform]) < 2
platform not in self.valid_formats()
or len(self.valid_formats()[platform]) < 2
): # check that the platform and version are valid
raise ObjectReadError(
f"{platform} is not a valid platform for this wrapper."
Expand Down
4 changes: 3 additions & 1 deletion amulet/level/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def report(self):
print(obj_name, obj)


Translators = Loader[Translator](Translator, "translator", f"{ParentPackage}.translators")
Translators = Loader[Translator](
Translator, "translator", f"{ParentPackage}.translators"
)
Interfaces = Loader[Interface](Interface, "interface", f"{ParentPackage}.interfaces")
Formats = Loader[FormatWrapper](
FormatWrapper, "format", f"{ParentPackage}.formats", create_instance=False
Expand Down
13 changes: 3 additions & 10 deletions tests/test_format_wrapper/test_create_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ def _test_create(
platform=platform,
version=version,
bounds=SelectionGroup([SelectionBox((0, 0, 0), (1, 1, 1))]),
overwrite=True
overwrite=True,
)
else:
level = cls.create_and_open(
path=path,
platform=platform,
version=version,
overwrite=True
path=path, platform=platform, version=version, overwrite=True
)

self.assertTrue(level.is_open, "The level was not opened by create_and_open()")
Expand Down Expand Up @@ -92,11 +89,7 @@ def _test_create(
bounds=SelectionGroup([SelectionBox((0, 0, 0), (1, 1, 1))]),
)
else:
cls.create_and_open(
path=path,
platform=platform,
version=version
)
cls.create_and_open(path=path, platform=platform, version=version)

clean_path(path)

Expand Down

0 comments on commit f45c27b

Please sign in to comment.