Skip to content

Commit bfae638

Browse files
authored
feat: update to 3.14, newest beet/bolt (#92)
* feat: fix up examples, linting, and more * fixes using tellraw with Sources * chore: fix up gh action * chore: fix pyproject.toml version lookup * chore: fix up pyproject st uff * chore: update rich * chore: git checkout * chore: condition to semantic release
1 parent 8be6518 commit bfae638

37 files changed

Lines changed: 803 additions & 1176 deletions

File tree

.github/workflows/docs.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python 3.10
20-
uses: actions/setup-python@v2
18+
- uses: actions/checkout@v6
19+
20+
- name: Set up Python 3.14
21+
uses: actions/setup-python@v6
2122
with:
22-
python-version: "3.10"
23+
python-version: ${{ env.PYTHON_VERSION }}
24+
2325
- name: Install uv
24-
uses: astral-sh/setup-uv@v4
26+
uses: astral-sh/setup-uv@v7
2527
with:
2628
enable-cache: true
29+
2730
- name: Install dependencies
28-
run: uv sync
31+
run: uv sync --all-groups
32+
2933
- name: Build and deploy documentation
3034
run: |
3135
git config --global user.name "github-actions"
3236
git config --global user.email "action@github.com"
33-
uv run mudkip build --check --update-gh-pages --repository https://x-access-token:${GH_TOKEN}@github.com/rx-modules/bolt-expressions
37+
uv run mudkip build --check --update-gh-pages --repository https://x-access-token:${GH_TOKEN}@github.com/rx-modules/bolt-expressions

.github/workflows/main.yml

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,92 @@ on:
66
pull_request:
77
branches: [main]
88

9+
env:
10+
PYTHON_VERSION: "3.14"
11+
912
jobs:
10-
main:
13+
release:
1114
name: Test and release
1215
runs-on: ubuntu-latest
1316

1417
steps:
1518
- uses: actions/checkout@v6
16-
with:
17-
fetch-depth: 0
1819

19-
- name: Set up Python 3.10
20+
- name: Set up Python 3.14
2021
uses: actions/setup-python@v6
2122
with:
22-
python-version: "3.12"
23+
python-version: ${{ env.PYTHON_VERSION }}
2324

2425
- name: Install uv
2526
uses: astral-sh/setup-uv@v7
2627
with:
2728
enable-cache: true
2829

2930
- name: Install dependencies
30-
run: uv sync
31+
run: uv sync --all-groups
3132

3233
- name: Run tests
3334
run: uv run pytest -v
3435

3536
- name: Check formatting
36-
run: uv run ruff format --check src/bolt_expressions examples tests
37+
run: uv run ruff check
3738

38-
- name: Check imports
39-
run: uv run ruff check --select I src/bolt_expressions examples tests
39+
- name: Action | Semantic Version Release
40+
id: release
41+
if: github.ref == 'refs/heads/main'
42+
run: |
43+
# 1. Run the versioning logic
44+
uv run semantic-release version
4045
41-
- name: Release
42-
if: |
43-
github.repository == 'rx-modules/bolt-expressions'
44-
&& github.event_name == 'push'
45-
&& github.ref == 'refs/heads/main'
46+
# 2. Extract version info for subsequent steps
47+
echo "tag=$(uv run semantic-release version --print-tag)" >> $GITHUB_OUTPUT
48+
49+
# 3. Check if a release actually happened
50+
if [ -d "dist" ] && [ "$(ls -A dist)" ]; then
51+
echo "released=true" >> $GITHUB_OUTPUT
52+
fi
4653
env:
4754
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
49-
run: |
50-
git config --global user.name "github-actions"
51-
git config --global user.email "action@github.com"
52-
uv run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>"
55+
56+
- name: Publish | Upload to GitHub Release Assets
57+
uses: python-semantic-release/publish-action@v10.5.3
58+
if: steps.release.outputs.released == 'true'
59+
with:
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
tag: ${{ steps.release.outputs.tag }}
62+
63+
- name: Upload | Distribution Artifacts
64+
uses: actions/upload-artifact@v4
65+
if: steps.release.outputs.released == 'true'
66+
with:
67+
name: distribution-artifacts
68+
path: dist
69+
if-no-files-found: error
70+
71+
deploy:
72+
# 1. Separate out the deploy step from the publish step to run each step at
73+
# the least amount of token privilege
74+
# 2. Also, deployments can fail, and its better to have a separate job if you need to retry
75+
# and it won't require reversing the release.
76+
runs-on: ubuntu-latest
77+
needs: release
78+
if: ${{ needs.release.outputs.released == 'true' }}
79+
80+
permissions:
81+
contents: read
82+
id-token: write
83+
84+
steps:
85+
- name: Setup | Download Build Artifacts
86+
uses: actions/download-artifact@v4
87+
id: artifact-download
88+
with:
89+
name: distribution-artifacts
90+
path: dist
91+
92+
- name: Publish package distributions to PyPI
93+
uses: pypa/gh-action-pypi-publish@release/v1
94+
with:
95+
packages-dir: dist
96+
print-hash: true
97+
verbose: true

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12
1+
3.14

examples/composite_literal/beet.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: bolt-expressions-composite-literal
2-
minecraft: "1.20"
32

43
data_pack:
54
load: [src]

examples/operation_condition/beet.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: bolt-expressions-operation-condition
2-
minecraft: "1.20"
32

43
data_pack:
54
load: [src]

examples/source_typing/beet.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: bolt-expressions-source-typing
2-
minecraft: "1.20"
32

43
data_pack:
54
load: [src]

pyproject.toml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"bolt>=0.38",
1818
"frozendict>=2.4.0,<3",
1919
"bolt-control-flow>=0.2.0",
20-
"rich>=12.4.4,<13",
20+
"rich>=13.2.0",
2121
]
2222
description = "Provides pandas-like expressions capabilities to the bolt extension of mecha"
2323
keywords = [
@@ -30,7 +30,7 @@ keywords = [
3030
license = "MIT"
3131
name = "bolt-expressions"
3232
readme = "README.md"
33-
requires-python = ">=3.10,<4.0"
33+
requires-python = ">=3.14,<4.0"
3434
version = "0.18.0"
3535

3636
[project.urls]
@@ -40,7 +40,7 @@ Repository = "https://github.com/rx-modules/bolt-expressions"
4040

4141
[dependency-groups]
4242
dev = [
43-
"python-semantic-release>=7.27.0,<8",
43+
"python-semantic-release>=9.21.0",
4444
"mudkip>=0.5.1",
4545
"pytest-insta>=0.1.11",
4646
"pygments",
@@ -50,6 +50,7 @@ dev = [
5050
[tool.uv]
5151

5252
[tool.uv.sources]
53+
bolt-control-flow = {git = "https://github.com/rx-modules/bolt-control-flow", rev = "chore/update-to-uv-py-3-14"}
5354
pygments = {git = "https://github.com/rx-modules/pygments"}
5455

5556
[build-system]
@@ -59,21 +60,17 @@ requires = ["uv_build>=0.9.26,<0.10.0"]
5960
[tool.pytest.ini_options]
6061
addopts = "tests src/bolt_expressions" # --doctest-modules"
6162
minversion = "6.0"
62-
# doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS"
6363

64-
[tool.black]
65-
include = '\.pyi?$'
66-
target-version = ["py310"]
67-
68-
[tool.isort]
69-
profile = "black"
64+
[tool.ruff.lint]
65+
ignore = ["F403"] # allows "*" imports
7066

7167
[tool.semantic_release]
72-
branch = "main"
73-
build_command = "uv run mudkip build --update-gh-pages --repository https://x-access-token:${GH_TOKEN}@github.com/rx-modules/bolt-expressions"
68+
build_command = "uv build"
7469
major_on_zero = false
75-
version_toml = "pyproject.toml:project.version"
76-
version_variable = ["bolt_expressions/__init__.py:__version__"]
70+
71+
commit_author = "github-actions <action@github.com>"
72+
version_toml = ["pyproject.toml:project.version"]
73+
version_variables = ["src/bolt_expressions/__init__.py:__version__"]
7774

7875
[tool.mudkip]
7976
preset = "furo"

src/bolt_expressions/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def add_objective(self, name: str, criteria: str = "dummy"):
6565
def add_constant(self, value: int):
6666
holder, obj = self.expr.const_score(value)
6767

68-
if not value in self.constants:
68+
if value not in self.constants:
6969
self.constants.add(value)
7070
self.expr.init_commands.append(
7171
f"scoreboard players set {holder} {obj} {value}"

src/bolt_expressions/ast.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
Reducer,
1414
rule,
1515
)
16+
import nbtlib
1617

1718
from .sources import Source
1819

1920
__all__ = [
2021
"RunExecuteTransformer",
2122
"ConstantScoreChecker",
2223
"ObjectiveChecker",
23-
"SourceJsonConverter",
24+
"SourceNBTConverter",
2425
]
2526

2627

@@ -80,20 +81,20 @@ def objective(self, node: AstObjective):
8081

8182

8283
@dataclass
83-
class SourceJsonConverter:
84+
class SourceNBTConverter:
8485
converter: Callable[[Any, AstNode], AstNode]
8586

8687
def convert(self, obj: Any) -> Any:
8788
if isinstance(obj, Source):
88-
return obj.component()
89+
return self.convert(obj.component())
8990

9091
if isinstance(obj, (list, tuple)):
9192
list_value = cast(list[Any], obj)
92-
return [self.convert(value) for value in list_value]
93+
return nbtlib.List([self.convert(value) for value in list_value])
9394

9495
if isinstance(obj, dict):
9596
dict_value = cast(dict[str, Any], obj)
96-
return {key: self.convert(value) for key, value in dict_value.items()}
97+
return nbtlib.Compound({key: self.convert(value) for key, value in dict_value.items()})
9798

9899
return obj
99100

src/bolt_expressions/check.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
Any,
55
Iterable,
66
TypedDict,
7-
Union,
87
get_args,
98
get_type_hints,
10-
is_typeddict,
119
)
1210

1311
from beet import Context
@@ -16,7 +14,6 @@
1614
from nbtlib import (
1715
Array,
1816
Byte,
19-
Compound,
2017
Double,
2118
Float,
2219
Int,
@@ -39,7 +36,6 @@
3936
)
4037
from .typing import (
4138
NbtType,
42-
NbtValue,
4339
NumericNbtValue,
4440
access_type,
4541
convert_type,

0 commit comments

Comments
 (0)