Skip to content

Commit

Permalink
Add typing overloads for sweep_for_advancements
Browse files Browse the repository at this point in the history
This makes it so type-checkers and IDEs can see which calls return
`None` and which calls return `Iterator` so that it doesn't complain
about returning an `Iterator` from `sweep_for_events` or about iterating
through `None` in `can_beat_game`.

Co-authored-by: Doug Hoskisson <[email protected]>
  • Loading branch information
Mysteryem and beauxq authored Oct 15, 2024
1 parent f3a07cd commit 46490c9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ def _sweep_for_advancements_impl(self, advancements_per_player: List[Tuple[int,
if yield_each_sweep:
yield

@typing.overload
def sweep_for_advancements(self, locations: Optional[Iterable[Location]] = None, *,
yield_each_sweep: typing.Literal[True],
checked_locations: Optional[Set[Location]] = None) -> Iterator[None]: ...

@typing.overload
def sweep_for_advancements(self, locations: Optional[Iterable[Location]] = None,
yield_each_sweep: typing.Literal[False] = False,
checked_locations: Optional[Set[Location]] = None) -> None: ...

def sweep_for_advancements(self, locations: Optional[Iterable[Location]] = None, yield_each_sweep: bool = False,
checked_locations: Optional[Set[Location]] = None) -> Optional[Iterator[None]]:
"""
Expand Down

0 comments on commit 46490c9

Please sign in to comment.