From 430d4881812237ff797fe7d4499a008a9c65cb3c Mon Sep 17 00:00:00 2001 From: Valentin Berlier Date: Sun, 31 Dec 2023 01:54:57 +0100 Subject: [PATCH] fix: compat with mecha.contrib.json_files when it comes before bolt --- bolt/parse.py | 2 +- examples/bolt_json/beet.yml | 7 ++++ .../data/minecraft/tags/functions/load.json | 8 +++++ poetry.lock | 8 ++--- pyproject.toml | 2 +- .../examples__build_bolt_json__0.pack.md | 34 +++++++++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 examples/bolt_json/beet.yml create mode 100644 examples/bolt_json/src/data/minecraft/tags/functions/load.json create mode 100644 tests/snapshots/examples__build_bolt_json__0.pack.md diff --git a/bolt/parse.py b/bolt/parse.py index 0254143..ce129a8 100644 --- a/bolt/parse.py +++ b/bolt/parse.py @@ -629,7 +629,7 @@ def __call__(self, stream: TokenStream) -> Any: self.macro_handler.cache_local_spec(stream) - if isinstance(node, AstRoot) and not isinstance(current, Function): + if type(node) is AstRoot and not isinstance(current, Function): node = set_location(AstNonFunctionRoot(commands=node.commands), node) return node diff --git a/examples/bolt_json/beet.yml b/examples/bolt_json/beet.yml new file mode 100644 index 0000000..df71527 --- /dev/null +++ b/examples/bolt_json/beet.yml @@ -0,0 +1,7 @@ +require: + - mecha.contrib.json_files + - bolt +data_pack: + load: "src" +pipeline: + - mecha diff --git a/examples/bolt_json/src/data/minecraft/tags/functions/load.json b/examples/bolt_json/src/data/minecraft/tags/functions/load.json new file mode 100644 index 0000000..17e4fdf --- /dev/null +++ b/examples/bolt_json/src/data/minecraft/tags/functions/load.json @@ -0,0 +1,8 @@ +name = demo:foo + +{ + "values": [name] +} + +function name: + say hello diff --git a/poetry.lock b/poetry.lock index dd16022..a2c111a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -714,14 +714,14 @@ files = [ [[package]] name = "mecha" -version = "0.85.1" +version = "0.86.0" description = "A powerful Minecraft command library" category = "main" optional = false python-versions = ">=3.10,<4.0" files = [ - {file = "mecha-0.85.1-py3-none-any.whl", hash = "sha256:18dc81e9a0f68f03995eef1a6cac52cd004b7a873fea26e92a5c2f54442b0ce0"}, - {file = "mecha-0.85.1.tar.gz", hash = "sha256:33471e5ba1fb5d408022f7fc7a84153e69c67f3fb5fe3d0c35ba74c68301fcd6"}, + {file = "mecha-0.86.0-py3-none-any.whl", hash = "sha256:75f8b1f6bd3a197c379bfbb96b3018585cc7d39134f9054861b232eefd8c4eef"}, + {file = "mecha-0.86.0.tar.gz", hash = "sha256:69177b1f46ada51f31830adf42f6fc743505d4ff494b774718016c58460468c6"}, ] [package.dependencies] @@ -1581,4 +1581,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "e816ce7da670ec855fdd6bdef51b42b139820f6a9b192bdf8aeba2cfc92d5d07" +content-hash = "51bd7a524a33410ea80a59619fd50bfad30a9a2f3b21cbb73e156bb680d01801" diff --git a/pyproject.toml b/pyproject.toml index 0b53966..5b516c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ include = ["bolt/py.typed"] [tool.poetry.dependencies] python = "^3.10" beet = ">=0.100.0" -mecha = ">=0.85.1" +mecha = ">=0.86.0" [tool.poetry.group.dev.dependencies] pytest = "^7.4.3" diff --git a/tests/snapshots/examples__build_bolt_json__0.pack.md b/tests/snapshots/examples__build_bolt_json__0.pack.md new file mode 100644 index 0000000..3de9bab --- /dev/null +++ b/tests/snapshots/examples__build_bolt_json__0.pack.md @@ -0,0 +1,34 @@ +# Lectern snapshot + +## Data pack + +`@data_pack pack.mcmeta` + +```json +{ + "pack": { + "pack_format": 26, + "description": "" + } +} +``` + +### minecraft + +`@function_tag minecraft:load` + +```json +{ + "values": [ + "demo:foo" + ] +} +``` + +### demo + +`@function demo:foo` + +```mcfunction +say hello +```