Bolt-expressions

Latest version: v0.16.0

Safety actively analyzes 624811 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 6

3.14

a = (b*50)/157




Fix
* Make wrapped min/max functions behave more like the builtin ones ([`7e3b400`](https://github.com/rx-modules/bolt-expressions/commit/7e3b4003e677bf7a1bd9c4728f332f63e6a12081))
py
storage = Data.storage(example:temp)
a, b, c = obj["$a", "$b", "$c"]

variadic arguments
m = min(a, b, c)

nested min/max calls
n = max(0, min(a, 100))

iterable
values = (a, b, c, storage.value, *obj["$j", "$k"])
o = max(values)

* Remove commands that multiply/divide by 1, add/subtract by 0 ([`6d8cf88`](https://github.com/rx-modules/bolt-expressions/commit/6d8cf882b029d49b120116ed088ee395d3902132))

1.5

a = (b * 3)/2

0.16.0

Feature

* Overloaded len function for data sources ([`792657b`](https://github.com/rx-modules/bolt-expressions/commit/792657baa2de8c9f5d88c8e15c22363d97550ce6))
py
obj["$length"] = len(storage.arr)
execute store result score $length obj run data get storage name:path arr

storage.last_slot[Byte] = len(storage.Items) - 1
execute store result score $i0 bolt.expr.temp run data get storage name:path Items
execute store result storage name:path last_slot byte 1 run scoreboard players remove $i0 bolt.expr.temp 1



* Add string data source indexing and slicing ([`4b5fa58`](https://github.com/rx-modules/bolt-expressions/commit/4b5fa58cb83efdc6fcfadc3f270631786b7c1298))
py
must specify the data type
message = storage.msg[str]

storage.a = message[5:]
data modify storage name:path a set string storage name:path msg 5

storage.chars.append(message[0])
data modify storage name:path chars append string storage name:path msg 0 1

message[0] = "c"
TypeError: String data source does not support index/slice assignment.

storage.value[0] list indexing
storage.value[0:5] generic data sources dont accept slices


Fix

* Add store result inlining rule ([`006750b`](https://github.com/rx-modules/bolt-expressions/commit/006750bfb95d2ab1c29a95d21e3204c599d8405a))
* Lazy sources should discard previous value when reused ([`2101335`](https://github.com/rx-modules/bolt-expressions/commit/2101335ad560208d2f2f38959f5ea8966c5baf80))

0.15.0

Feature

* Add source branching and comparison operators ([`f8d8ec4`](https://github.com/rx-modules/bolt-expressions/commit/f8d8ec4b3612d080e17808e0a9bf02d3256a3f23))
py
a, b, c = obj["$a", "$b", "$c"]
value = storage.value

if not a:
a = 0

if a > b:
say a greater than b!

c = (a <= b)*50 + (value >= 3)*3

* Improved if..elif..else with `__multibranch__` ([`1746226`](https://github.com/rx-modules/bolt-expressions/commit/174622679945b3b09634316e212036d195eb51e6))
py
if not a:
say a is 0 or does not exist
elif a < 0:
say a is negative
elif a > 0:
say a is positive
else:
say impossible

* Data comparison operator ([`749dd79`](https://github.com/rx-modules/bolt-expressions/commit/749dd79b6e96c4bec0fa79eaff9733982e1649c5))
py
from nbtlib import Byte

item = storage.item

execute if data storage test:temp item{id: "minecraft:stone"} ...
if item.id == "minecraft:stone":
say holding a stone!

execute if data storage test:temp item{Count: 1b}
if item.Count == Byte(1):
say just one item.

matching a compound
if item == {id: "minecraft:diamond", Count: Byte(3)}:
...

matching a score
if storage.time == obj["$time"]:
say ...

comparing two data sources
if storage.value != storage.prev_value:
say value changed!
storage.prev_value = storage.value
else:
say value not changed.


* Add and/or operator support for sources/lazy sources ([`f8013e9`](https://github.com/rx-modules/bolt-expressions/commit/f8013e94feac584b470ebbadeb861423b24c4416))

Fix

* Strip run execute from commands ([`c8648f2`](https://github.com/rx-modules/bolt-expressions/commit/c8648f229aa2201384d91d0bbcb7a9864133c4b9))

0.14.0

Feature

* Operations now return lazy sources ([`6832b91`](https://github.com/rx-modules/bolt-expressions/commit/6832b9173d15ae6a88dd9d7d5b21929b459e41e6))
py
a = 5 + obj["s"] / 2
$2384k242hd495_2 bolt.expr.temp (generated name)
does not emit any command yet

print(a.is_lazy()) True

obj["$value"] = obj["$b"] * a
expanded on expression while it's lazy.
might produce repeated commands if "a" switches
to early evaluation later on.

a.evaluate()
triggers early evaluation of "a".
commands are inserted where "a" was originally evaluated.

print(a.is_lazy()) False

obj["$value2"] = a copies "a"

* Support dicts, lists, arrays and union types as data source types ([`1097f5f`](https://github.com/rx-modules/bolt-expressions/commit/1097f5fedf8a7211c5437deeeac50eadd256ae03))
py

class Item(TypedDict): from the typing module
id: str
Count: Byte from nbtlib
tag: dict[str, Any]

hotbar = storage.hotbar[list[Item]]
first_item = hotbar[0]
first_item.Count = obj["$count"]
execute store result storage ... hotbar[0].Count byte 1 run scoreboard players get ...

* Type checking ([`b031303`](https://github.com/rx-modules/bolt-expressions/commit/b0313037e4428dd5e41cc7c608931cf613c6701f))
py

first_item.id = 5
"Int" does not match "String"

hotbar.append({id: "stone"})
"{id: String}" is missing required key "Count" of type "Byte"

hotbar[0].merge({x:5})
"{x: Int}" has extra key "x" not present in "Item"

hotbar = [1, 2, 3]
Elements of "list[Int]" and "list[Item]" are not compatible
"Int" is not a compound type with fixed keys and is not compatible with "Item"

message = storage.msg[str | list[str]]

message = ["hello", "world"]
fine
message = "hello world"
fine
message = [{a: "b"}, {b: 5}]
"list[{a: String} | {b: Int}]" is not compatible with "String | list[String]"


* Numeric literal casting ([`9874ca9`](https://github.com/rx-modules/bolt-expressions/commit/9874ca91f2c7045ffc8fbf17b06505984f2870c2))
py
storage.pos[list[Double]] = [43, 0, 5]
[43.0d, 0.0d, 5.0d]

storage.item[Item] = {id: "glass", Count: 5, tag: {}}
{id: "glass", Count: 5b, tag: {}}

storage.flag[Byte] = 128
raises an exception because 128 can't be represented as Byte.

storage.number[Byte | Long] = 4 can't cast when write type is a union
"Int" is not compatible with "Byte | Long"

storage.number[Byte | None] = 4 only if it's optional
4b

* Separate data source interfaces for each nbt type ([`dbe9a74`](https://github.com/rx-modules/bolt-expressions/commit/dbe9a74f31f3c58fb1b34a5069edada983535ec9))
py
storage.msg[str] - 1
TypeError: unsupported operand type(s) for -: 'DataSource' and 'int'

storage.value[int].oops
TypeError: Data source of type 'Int' does not have named keys

storage.c[dict[str, Any]][0]
TypeError: Data source of type 'dict[String, typing.Any]' object is not indexable

storage.arr[list[int]]({a: 0})
TypeError: Data source of type 'list[Int]' does not support compound matching


Fix

* Only cast numeric nbt types ([`86d49b1`](https://github.com/rx-modules/bolt-expressions/commit/86d49b1b257996ded2c5becef223c9e6806b3c6a))

0.13.1

Fix

* Remove rich import ([`a07da7d`](https://github.com/rx-modules/bolt-expressions/commit/a07da7d539b1d0289d539d82493de8ed465d9e28))

Page 1 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.