Skip to content

Commit b0d747f

Browse files
committed
Fix strange None assert in callbacks, and callback changelog #280
1 parent a6a7c4c commit b0d747f

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

CHANGELOG.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ Changes:
1616
Breaking changes
1717

1818
- Changed Space.shapes, Space.bodies and Space.constraints to return a KeysView of instead of a list of the items. Note that this means the returned collection is no longer a copy. To get the old behavior, you can convert to list manually, like list(space.shapes).
19-
- At least one of the two bodies attached to constraint/joint must be dynamic.
19+
- At least one of the two bodies attached to constraint/joint must be dynamic.
2020
- Vec2d now supports bool to test if zero. (bool(Vec2d(2,3) == True) Note this is a breaking change.
21-
- Added Vec2d.length_squared, and depreacted Vec2d.get_length_sqrd()
21+
- Added Vec2d.length_squared, and deprecated Vec2d.get_length_sqrd()
2222
- Added Vec2d.get_distance_squared(), and deprecated Vec2d.get_dist_sqrd()
2323
- A dynamic body must have non-zero mass when calling Space.step (either from Body.mass, or by setting mass or density on a Shape attached to the Body). Its not valid to set mass to 0 on a dynamic body attached to a space.
24-
- Deprecated matplotlib_util. If you think this is a useful module and you use it, please create an issue on the Pymunk issue track
24+
- Deprecated matplotlib_util. If you think this is a useful module, and you use it, please create an issue on the Pymunk issue track
2525
- Dropped support for Python 3.8
2626
- Changed body.constraints to return a KeysView of the Constraints attached to the body. Note that its still weak references to the Constraints.
2727
- Reversed the dependency between bodies and shapes. Now the Body owns the connection, and the Shape only keeps a weak ref to the Body. That means that if you remove a Body, then any shapes not referenced anywhere else will also be removed.
2828
- Changed body.shapes to return a KeysView instead of a set of the shapes.
2929
- Changed Shape.segment_query to return None in case the query did not hit the shape.
3030
- Changed ContactPointSet.points to be a tuple and not list to make it clear its length is fixed.
31-
- Added default do_nothing and always_collide callback functions to the CollisionHandler, so that its clear how to reset and align with other callbacks. If in old code you did handler.begin = None, you should now instead to handler.begin = CollisionHandler.always_collide etc.
31+
- Added default do_nothing and always_collide callback functions to the CollisionHandler, so that its clear how to reset and align with other callbacks.
3232

3333
New non-breaking features
3434
- Switched from using Chipmunk to the new Munk2D fork of Chipmunk (see https://github.com/viblo/Munk2D for details).

pymunk/collision_handler.py

-12
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ def begin(self) -> _CollisionCallbackBool:
7676

7777
@begin.setter
7878
def begin(self, func: _CollisionCallbackBool) -> None:
79-
assert (
80-
func is not None
81-
), "To reset the begin callback, set handler.begin = CollisionHandler.always_collide"
8279
self._begin = func
8380

8481
if self._begin == CollisionHandler.always_collide:
@@ -102,9 +99,6 @@ def pre_solve(self) -> _CollisionCallbackBool:
10299

103100
@pre_solve.setter
104101
def pre_solve(self, func: _CollisionCallbackBool) -> None:
105-
assert (
106-
func is not None
107-
), "To reset the pre_solve callback, set handler.pre_solve = CollisionHandler.always_collide"
108102
self._pre_solve = func
109103

110104
if self._pre_solve == CollisionHandler.always_collide:
@@ -127,9 +121,6 @@ def post_solve(self) -> _CollisionCallbackNoReturn:
127121

128122
@post_solve.setter
129123
def post_solve(self, func: _CollisionCallbackNoReturn) -> None:
130-
assert (
131-
func is not None
132-
), "To reset the post_solve callback, set handler.post_solve = CollisionHandler.do_nothing"
133124
self._post_solve = func
134125

135126
if self._post_solve == CollisionHandler.do_nothing:
@@ -154,9 +145,6 @@ def separate(self) -> _CollisionCallbackNoReturn:
154145

155146
@separate.setter
156147
def separate(self, func: _CollisionCallbackNoReturn) -> None:
157-
assert (
158-
func is not None
159-
), "To reset the separate callback, set handler.separate = CollisionHandler.do_nothing"
160148
self._separate = func
161149

162150
if self._separate == CollisionHandler.do_nothing:

0 commit comments

Comments
 (0)