Skip to content

Commit 2f7c767

Browse files
committed
Clean up formatting.
Needed to keep up with changes to Black.
1 parent a04ffd4 commit 2f7c767

5 files changed

Lines changed: 41 additions & 34 deletions

File tree

tcod/_internal.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ def _fmt(string: str, stacklevel: int = 2) -> bytes:
130130

131131

132132
class _PropagateException:
133-
""" context manager designed to propagate exceptions outside of a cffi
134-
callback context. normally cffi suppresses the exception
133+
"""Context manager designed to propagate exceptions outside of a cffi
134+
callback context. Normally cffi suppresses the exception.
135135
136-
when propagate is called this class will hold onto the error until the
137-
control flow leaves the context, then the error will be raised
136+
When propagate is called this class will hold onto the error until the
137+
control flow leaves the context, then the error will be raised.
138138
139139
with _PropagateException as propagate:
140140
# give propagate as onerror parameter for ffi.def_extern
@@ -145,25 +145,25 @@ def __init__(self) -> None:
145145
self.exc_info = None # type: Any
146146

147147
def propagate(self, *exc_info: Any) -> None:
148-
""" set an exception to be raised once this context exits
148+
"""Set an exception to be raised once this context exits.
149149
150-
if multiple errors are caught, only keep the first exception raised
150+
If multiple errors are caught, only keep the first exception raised.
151151
"""
152152
if not self.exc_info:
153153
self.exc_info = exc_info
154154

155155
def __enter__(self) -> Callable[[Any], None]:
156-
""" once in context, only the propagate call is needed to use this
157-
class effectively
156+
"""Once in context, only the propagate call is needed to use this
157+
class effectively.
158158
"""
159159
return self.propagate
160160

161161
def __exit__(self, type: Any, value: Any, traceback: Any) -> None:
162-
""" if we're holding on to an exception, raise it now
162+
"""If we're holding on to an exception, raise it now.
163163
164-
prefers our held exception over any current raising error
164+
Prefers our held exception over any current raising error.
165165
166-
self.exc_info is reset now in case of nested manager shenanigans
166+
self.exc_info is reset now in case of nested manager shenanigans.
167167
"""
168168
if self.exc_info:
169169
type, value, traceback = self.exc_info

tcod/console.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ def __init__(
132132

133133
@classmethod
134134
def _from_cdata(cls, cdata: Any, order: str = "C") -> "Console":
135-
"""Return a Console instance which wraps this `TCOD_Console*` object.
136-
"""
135+
"""Return a Console instance which wraps this `TCOD_Console*` object."""
137136
if isinstance(cdata, cls):
138137
return cdata
139138
self = object.__new__(cls) # type: Console
@@ -419,8 +418,7 @@ def __deprecate_defaults(
419418
alignment: Any = ...,
420419
clear: Any = ...,
421420
) -> None:
422-
"""Return the parameters needed to recreate the current default state.
423-
"""
421+
"""Return the parameters needed to recreate the current default state."""
424422
if not __debug__:
425423
return
426424

tcod/event.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,9 @@ def ev_mousebuttondown(
905905
) -> Optional[T]:
906906
"""Called when a mouse button is pressed."""
907907

908-
def ev_mousebuttonup(self, event: "tcod.event.MouseButtonUp") -> Optional[T]:
908+
def ev_mousebuttonup(
909+
self, event: "tcod.event.MouseButtonUp"
910+
) -> Optional[T]:
909911
"""Called when a mouse button is released."""
910912

911913
def ev_mousewheel(self, event: "tcod.event.MouseWheel") -> Optional[T]:
@@ -929,21 +931,29 @@ def ev_windowexposed(self, event: "tcod.event.WindowEvent") -> Optional[T]:
929931
def ev_windowmoved(self, event: "tcod.event.WindowMoved") -> Optional[T]:
930932
"""Called when the window is moved."""
931933

932-
def ev_windowresized(self, event: "tcod.event.WindowResized") -> Optional[T]:
934+
def ev_windowresized(
935+
self, event: "tcod.event.WindowResized"
936+
) -> Optional[T]:
933937
"""Called when the window is resized."""
934938

935939
def ev_windowsizechanged(
936940
self, event: "tcod.event.WindowResized"
937941
) -> Optional[T]:
938942
"""Called when the system or user changes the size of the window."""
939943

940-
def ev_windowminimized(self, event: "tcod.event.WindowEvent") -> Optional[T]:
944+
def ev_windowminimized(
945+
self, event: "tcod.event.WindowEvent"
946+
) -> Optional[T]:
941947
"""Called when the window is minimized."""
942948

943-
def ev_windowmaximized(self, event: "tcod.event.WindowEvent") -> Optional[T]:
949+
def ev_windowmaximized(
950+
self, event: "tcod.event.WindowEvent"
951+
) -> Optional[T]:
944952
"""Called when the window is maximized."""
945953

946-
def ev_windowrestored(self, event: "tcod.event.WindowEvent") -> Optional[T]:
954+
def ev_windowrestored(
955+
self, event: "tcod.event.WindowEvent"
956+
) -> Optional[T]:
947957
"""Called when the window is restored."""
948958

949959
def ev_windowenter(self, event: "tcod.event.WindowEvent") -> Optional[T]:
@@ -957,13 +967,17 @@ def ev_windowfocusgained(
957967
) -> Optional[T]:
958968
"""Called when the window gains keyboard focus."""
959969

960-
def ev_windowfocuslost(self, event: "tcod.event.WindowEvent") -> Optional[T]:
970+
def ev_windowfocuslost(
971+
self, event: "tcod.event.WindowEvent"
972+
) -> Optional[T]:
961973
"""Called when the window loses keyboard focus."""
962974

963975
def ev_windowclose(self, event: "tcod.event.WindowEvent") -> Optional[T]:
964976
"""Called when the window manager requests the window to be closed."""
965977

966-
def ev_windowtakefocus(self, event: "tcod.event.WindowEvent") -> Optional[T]:
978+
def ev_windowtakefocus(
979+
self, event: "tcod.event.WindowEvent"
980+
) -> Optional[T]:
967981
pass
968982

969983
def ev_windowhittest(self, event: "tcod.event.WindowEvent") -> Optional[T]:

tcod/libtcodpy.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ def line_step() -> Union[Tuple[int, int], Tuple[None, None]]:
32313231
def line(
32323232
xo: int, yo: int, xd: int, yd: int, py_callback: Callable[[int, int], bool]
32333233
) -> bool:
3234-
""" Iterate over a line using a callback function.
3234+
"""Iterate over a line using a callback function.
32353235
32363236
Your callback function will take x and y parameters and return True to
32373237
continue iteration or False to stop iteration and return.
@@ -3263,7 +3263,7 @@ def line(
32633263

32643264
@deprecate("This function has been replaced by tcod.los.bresenham.")
32653265
def line_iter(xo: int, yo: int, xd: int, yd: int) -> Iterator[Tuple[int, int]]:
3266-
""" returns an Iterable
3266+
"""returns an Iterable
32673267
32683268
This Iterable does not include the origin point.
32693269
@@ -3627,9 +3627,7 @@ def noise_delete(n: tcod.noise.Noise) -> None:
36273627

36283628

36293629
def _unpack_union(type_: int, union: Any) -> Any:
3630-
"""
3631-
unpack items from parser new_property (value_converter)
3632-
"""
3630+
"""Unpack items from parser new_property (value_converter)"""
36333631
if type_ == lib.TCOD_TYPE_BOOL:
36343632
return bool(union.b)
36353633
elif type_ == lib.TCOD_TYPE_CHAR:

tcod/path.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,11 @@ class Dijkstra(_PathFinder):
272272
_path_delete = lib.TCOD_dijkstra_delete
273273

274274
def set_goal(self, x: int, y: int) -> None:
275-
"""Set the goal point and recompute the Dijkstra path-finder.
276-
"""
275+
"""Set the goal point and recompute the Dijkstra path-finder."""
277276
lib.TCOD_dijkstra_compute(self._path_c, x, y)
278277

279278
def get_path(self, x: int, y: int) -> List[Tuple[int, int]]:
280-
"""Return a list of (x, y) steps to reach the goal point, if possible.
281-
"""
279+
"""Return a list of (x, y) steps to reach the goal point, if possible."""
282280
lib.TCOD_dijkstra_path_set(self._path_c, x, y)
283281
path = []
284282
pointer_x = ffi.new("int[2]")
@@ -1210,8 +1208,7 @@ def add_root(self, index: Tuple[int, ...], value: int = 0) -> None:
12101208
lib.TCOD_frontier_push(self._frontier_p, index, value, value)
12111209

12121210
def _update_heuristic(self, goal_ij: Optional[Tuple[int, ...]]) -> bool:
1213-
"""Update the active heuristic. Return True if the heuristic changed.
1214-
"""
1211+
"""Update the active heuristic. Return True if the heuristic changed."""
12151212
if goal_ij is None:
12161213
heuristic = None
12171214
elif self._graph._heuristic is None:
@@ -1303,7 +1300,7 @@ def path_from(self, index: Tuple[int, ...]) -> np.ndarray:
13031300
index = index[::-1]
13041301
length = _check(
13051302
lib.get_travel_path(
1306-
self._graph._ndim, self._travel_p, index, ffi.NULL,
1303+
self._graph._ndim, self._travel_p, index, ffi.NULL
13071304
)
13081305
)
13091306
path = np.ndarray((length, self._graph._ndim), dtype=np.intc)

0 commit comments

Comments
 (0)