Skip to content

Commit a7372fb

Browse files
committed
Suppress internal warnings for deprecated tile attributes.
1 parent c8a704c commit a7372fb

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

tcod/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ def convert_event(self, event: _Event) -> _Event:
256256
event_copy = copy.copy(event)
257257
if isinstance(event, (tcod.event.MouseState, tcod.event.MouseMotion)):
258258
assert isinstance(event_copy, (tcod.event.MouseState, tcod.event.MouseMotion))
259-
event_copy.position = event.tile = tcod.event.Point(*self.pixel_to_tile(*event.position))
259+
event_copy.position = event._tile = tcod.event.Point(*self.pixel_to_tile(*event.position))
260260
if isinstance(event, tcod.event.MouseMotion):
261261
assert isinstance(event_copy, tcod.event.MouseMotion)
262+
assert event._tile is not None
262263
prev_tile = self.pixel_to_tile(
263264
event.position[0] - event.motion[0],
264265
event.position[1] - event.motion[1],
265266
)
266267
event_copy.motion = event.tile_motion = tcod.event.Point(
267-
event.tile[0] - prev_tile[0], event.tile[1] - prev_tile[1]
268+
event._tile[0] - prev_tile[0], event._tile[1] - prev_tile[1]
268269
)
269270
return event_copy
270271

tcod/event.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def __init__(
412412
) -> None:
413413
super().__init__()
414414
self.position = Point(*position)
415-
self.__tile = Point(*tile) if tile is not None else None
415+
self._tile = Point(*tile) if tile is not None else None
416416
self.state = state
417417

418418
@property
@@ -426,11 +426,6 @@ def pixel(self) -> Point:
426426

427427
@pixel.setter
428428
def pixel(self, value: Point) -> None:
429-
warnings.warn(
430-
"The mouse.pixel attribute is deprecated. Use mouse.position instead.",
431-
DeprecationWarning,
432-
stacklevel=2,
433-
)
434429
self.position = value
435430

436431
@property
@@ -440,16 +435,11 @@ def tile(self) -> Point:
440435
DeprecationWarning,
441436
stacklevel=2,
442437
)
443-
return _verify_tile_coordinates(self.__tile)
438+
return _verify_tile_coordinates(self._tile)
444439

445440
@tile.setter
446441
def tile(self, xy: tuple[int, int]) -> None:
447-
warnings.warn(
448-
"The mouse.tile attribute is deprecated. Use mouse.position of the event returned by context.convert_event instead.",
449-
DeprecationWarning,
450-
stacklevel=2,
451-
)
452-
self.__tile = Point(*xy)
442+
self._tile = Point(*xy)
453443

454444
def __repr__(self) -> str:
455445
return ("tcod.event.{}(position={!r}, tile={!r}, state={})").format(

0 commit comments

Comments
 (0)