Skip to content

Commit 153f2a5

Browse files
committed
apply sourcery review
1 parent 2e7f998 commit 153f2a5

1 file changed

Lines changed: 45 additions & 24 deletions

File tree

src/main/resources/python/bridge/wrappers.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def _handle_release(handle: Optional[int]) -> None:
4040
return
4141

4242
count = _handle_refcounts.get(handle, 0)
43-
if count <= 0:
44-
return
43+
44+
assert count > 0, "Cannot release zero handles."
4545

4646
if count == 1:
4747
_handle_refcounts.pop(handle, None)
@@ -881,7 +881,7 @@ def portal_cooldown(self) -> int:
881881
@portal_cooldown.setter
882882
def portal_cooldown(self, ticks: int):
883883
"""Set the portal cooldown value."""
884-
self._call_ff("setPortalCooldown", int(ticks))
884+
self._call_ff("setPortalCooldown", ticks)
885885

886886
@property
887887
def max_fire_ticks(self) -> int:
@@ -896,7 +896,7 @@ def freeze_ticks(self) -> int:
896896
@freeze_ticks.setter
897897
def freeze_ticks(self, ticks: int):
898898
"""Set the freeze ticks value."""
899-
self._call_ff("setFreezeTicks", int(ticks))
899+
self._call_ff("setFreezeTicks", ticks)
900900

901901
@property
902902
def height(self) -> float:
@@ -1067,7 +1067,7 @@ def villager_level(self) -> int:
10671067
@villager_level.setter
10681068
def villager_level(self, value: int):
10691069
"""Set the villager level value."""
1070-
self._call("setVillagerLevel", int(value))
1070+
self._call("setVillagerLevel", value)
10711071

10721072
@property
10731073
def villager_experience(self) -> int:
@@ -1077,7 +1077,7 @@ def villager_experience(self) -> int:
10771077
@villager_experience.setter
10781078
def villager_experience(self, value: int):
10791079
"""Set the villager experience value."""
1080-
self._call("setVillagerExperience", int(value))
1080+
self._call("setVillagerExperience", value)
10811081

10821082
@property
10831083
def recipes(self) -> list[dict]:
@@ -1172,7 +1172,7 @@ def item_drop_chance(self) -> float:
11721172
@item_drop_chance.setter
11731173
def item_drop_chance(self, value: float):
11741174
"""Set the item drop chance value."""
1175-
self._call("setItemDropChance", float(value))
1175+
self._call("setItemDropChance", value)
11761176

11771177
class FallingBlock(Entity):
11781178
"""FallingBlock entity."""
@@ -1210,7 +1210,7 @@ def damage_per_block(self) -> float:
12101210
@damage_per_block.setter
12111211
def damage_per_block(self, value: float):
12121212
"""Set the damage per block value."""
1213-
self._call("setDamagePerBlock", float(value))
1213+
self._call("setDamagePerBlock", value)
12141214

12151215
@property
12161216
def max_damage(self) -> int:
@@ -1220,7 +1220,7 @@ def max_damage(self) -> int:
12201220
@max_damage.setter
12211221
def max_damage(self, value: int):
12221222
"""Set the max damage value."""
1223-
self._call("setMaxDamage", int(value))
1223+
self._call("setMaxDamage", value)
12241224

12251225
class AreaEffectCloud(Entity):
12261226
"""AreaEffectCloud entity with radius and effect properties."""
@@ -1233,7 +1233,7 @@ def radius(self) -> float:
12331233
@radius.setter
12341234
def radius(self, value: float):
12351235
"""Set the radius value."""
1236-
self._call("setRadius", float(value))
1236+
self._call("setRadius", value)
12371237

12381238
@property
12391239
def color(self):
@@ -1253,7 +1253,7 @@ def duration(self) -> int:
12531253
@duration.setter
12541254
def duration(self, ticks: int):
12551255
"""Set the duration value."""
1256-
self._call("setDuration", int(ticks))
1256+
self._call("setDuration", ticks)
12571257

12581258
@property
12591259
def wait_time(self) -> int:
@@ -1263,7 +1263,7 @@ def wait_time(self) -> int:
12631263
@wait_time.setter
12641264
def wait_time(self, ticks: int):
12651265
"""Set the wait time value."""
1266-
self._call("setWaitTime", int(ticks))
1266+
self._call("setWaitTime", ticks)
12671267

12681268
@property
12691269
def radius_on_use(self) -> float:
@@ -1273,7 +1273,7 @@ def radius_on_use(self) -> float:
12731273
@radius_on_use.setter
12741274
def radius_on_use(self, value: float):
12751275
"""Set the radius on use value."""
1276-
self._call("setRadiusOnUse", float(value))
1276+
self._call("setRadiusOnUse", value)
12771277

12781278
@property
12791279
def radius_per_tick(self) -> float:
@@ -1283,7 +1283,7 @@ def radius_per_tick(self) -> float:
12831283
@radius_per_tick.setter
12841284
def radius_per_tick(self, value: float):
12851285
"""Set the radius per tick value."""
1286-
self._call("setRadiusPerTick", float(value))
1286+
self._call("setRadiusPerTick", value)
12871287

12881288
@property
12891289
def particle(self):
@@ -1590,7 +1590,7 @@ def uuid(self) -> str:
15901590

15911591
return result_text
15921592

1593-
raise Exception(f"Could not get UUID: {self}")
1593+
raise Exception(f"Could not get UUID: {self}") # sourcery skip: raise-specific-error
15941594

15951595
except Exception as exc:
15961596
raise BridgeError(f"Failed to synchronously resolve uuid: {exc}") from exc
@@ -1767,7 +1767,7 @@ def absorption(self) -> float:
17671767
@absorption.setter
17681768
def absorption(self, value: float):
17691769
"""Set the absorption value."""
1770-
self._call_ff("setAbsorptionAmount", float(value))
1770+
self._call_ff("setAbsorptionAmount", value)
17711771

17721772
@property
17731773
def saturation(self) -> float:
@@ -1777,7 +1777,7 @@ def saturation(self) -> float:
17771777
@saturation.setter
17781778
def saturation(self, value: float):
17791779
"""Set the saturation value."""
1780-
self._call_ff("setSaturation", float(value))
1780+
self._call_ff("setSaturation", value)
17811781

17821782
@property
17831783
def exhaustion(self) -> float:
@@ -1787,7 +1787,7 @@ def exhaustion(self) -> float:
17871787
@exhaustion.setter
17881788
def exhaustion(self, value: float):
17891789
"""Set the exhaustion value."""
1790-
self._call_ff("setExhaustion", float(value))
1790+
self._call_ff("setExhaustion", value)
17911791

17921792
@property
17931793
def attack_cooldown(self) -> float:
@@ -1880,7 +1880,7 @@ def max_health(self) -> float:
18801880
def max_health(self, value: float):
18811881
"""Set the max health value."""
18821882
self._invalidate_field("health")
1883-
self._call_ff("setMaxHealth", float(value))
1883+
self._call_ff("setMaxHealth", value)
18841884

18851885
@property
18861886
def bed_spawn_location(self) -> Location | None:
@@ -2121,7 +2121,11 @@ def set_block(self, x: int, y: int, z: int, material: Any, apply_physics: bool =
21212121
if isinstance(material, str):
21222122
material = Material.from_name(material.upper())
21232123

2124-
return _connection.call(target="region", method="setBlock", args=[self, int(x), int(y), int(z), material, apply_physics])
2124+
return _connection.call(
2125+
target="region",
2126+
method="setBlock",
2127+
args=[self, x, y, z, material, apply_physics],
2128+
)
21252129

21262130
def fill(self, pos1: Any, pos2: Any, material: Any, apply_physics: bool = False):
21272131
"""Fill a rectangular region with a block type."""
@@ -2150,15 +2154,32 @@ def fill_sphere(self, center: Any, radius: float, material: Any, hollow: bool =
21502154
if isinstance(material, str):
21512155
material = Material.from_name(material.upper())
21522156

2153-
return _connection.call(target="region", method="sphere", args=[self, float(cx), float(cy), float(cz), float(radius), material, hollow])
2157+
return _connection.call(
2158+
target="region",
2159+
method="sphere",
2160+
args=[self, float(cx), float(cy), float(cz), radius, material, hollow],
2161+
)
21542162

21552163
def fill_cylinder(self, center: Any, radius: float, height: int, material: Any, hollow: bool = False):
21562164
"""Fill a cylinder of blocks at a location."""
21572165
cx, cy, cz = _extract_xyz(center)
21582166
if isinstance(material, str):
21592167
material = Material.from_name(material.upper())
21602168

2161-
return _connection.call(target="region", method="cylinder", args=[self, float(cx), float(cy), float(cz), float(radius), int(height), material, hollow])
2169+
return _connection.call(
2170+
target="region",
2171+
method="cylinder",
2172+
args=[
2173+
self,
2174+
float(cx),
2175+
float(cy),
2176+
float(cz),
2177+
radius,
2178+
height,
2179+
material,
2180+
hollow,
2181+
],
2182+
)
21622183

21632184
def fill_line(self, start: Any, end: Any, material: Any):
21642185
"""Fill a line of blocks between two points."""
@@ -2846,7 +2867,7 @@ def furnace_burn_time(self) -> int:
28462867
@furnace_burn_time.setter
28472868
def furnace_burn_time(self, ticks: int):
28482869
"""Set the furnace burn time value."""
2849-
return self._call("setFurnaceBurnTime", int(ticks))
2870+
return self._call("setFurnaceBurnTime", ticks)
28502871

28512872
@property
28522873
def furnace_cook_time(self) -> int:
@@ -2856,7 +2877,7 @@ def furnace_cook_time(self) -> int:
28562877
@furnace_cook_time.setter
28572878
def furnace_cook_time(self, ticks: int):
28582879
"""Set the furnace cook time value."""
2859-
return self._call("setFurnaceCookTime", int(ticks))
2880+
return self._call("setFurnaceCookTime", ticks)
28602881

28612882
@property
28622883
def furnace_cook_time_total(self) -> int:

0 commit comments

Comments
 (0)