Skip to content

Commit

Permalink
Fix some mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davfsa committed Dec 23, 2021
1 parent 5f5f83e commit d145703
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions hikari/impl/event_manager_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@


def _generate_weak_listener(
reference: weakref.WeakMethod,
reference: weakref.WeakMethod[typing.Any],
) -> typing.Callable[[event_manager_.EventT], typing.Coroutine[typing.Any, typing.Any, None]]:
async def call_weak_method(event: event_manager_.EventT) -> None:
method = reference()
Expand Down Expand Up @@ -233,7 +233,7 @@ def open(self) -> None:
# listener with a weakref then try to close this on deletion. While this may lead to their consoles being
# spammed, this is a small price to pay as it'll be way more obvious what's wrong than if we just left them
# with a vague ominous memory leak.
reference = weakref.WeakMethod(self._listener) # type: ignore[arg-type]
reference = weakref.WeakMethod(self._listener)
listener = _generate_weak_listener(reference)
self._registered_listener = listener
self._event_manager.subscribe(self._event_type, listener)
Expand Down
25 changes: 16 additions & 9 deletions hikari/internal/enums.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@ class Flag(__enum.IntFlag):
def __len__(self) -> int: ...
@staticmethod
def __new__(cls: __Type[__FlagT], value: int = 0) -> __FlagT: ...
isdisjoint = is_disjoint
issuperset = is_superset
symmetricdifference = symmetric_difference
__contains__ = issubset = is_subset
__rand__ = __and__ = intersection
__ror__ = __or__ = union
__rsub__ = __sub__ = difference
__rxor__ = __xor__ = symmetric_difference
__invert__ = invert

# Aliases
def isdisjoint(self: __FlagT, other: __Union[int, __FlagT]) -> bool: ... # is_disjoint
def issuperset(self: __FlagT, other: __Union[int, __FlagT]) -> bool: ... # is_superset
def symmetricdifference(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # symmetric_difference
def issubset(self: __FlagT, other: __Union[int, __FlagT]) -> bool: ... # is_subset
def __contains__(self: __FlagT, other: __Union[int, __FlagT]) -> bool: ... # is_subset
def __rand__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # intersection
def __and__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # intersection
def __ror__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # union
def __or__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # union
def __rsub__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # difference
def __sub__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # difference
def __rxor__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # symmetric_difference
def __xor__(self: __FlagT, other: __Union[int, __FlagT]) -> __FlagT: ... # symmetric_difference
def __invert__(self: __FlagT) -> __FlagT: ... # invert

0 comments on commit d145703

Please sign in to comment.