Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davfsa committed Nov 18, 2023
1 parent 6903641 commit c26e26d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
54 changes: 29 additions & 25 deletions hikari/internal/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,21 @@ def __new__(

for name, value in namespace.names_to_values.items():
member = new_namespace.get(name)
if not isinstance(member, _DeprecatedAlias):
# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)
if isinstance(member, _DeprecatedAlias):
continue

# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

name_to_member[name] = member
value_to_member.setdefault(value, member)
value_to_member[value] = member
member_names.append(name)

return cls
Expand Down Expand Up @@ -471,24 +473,26 @@ def __new__(

for name, value in namespace.names_to_values.items():
member = new_namespace.get(name)
if not isinstance(member, _DeprecatedAlias):
# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

if not (value & value - 1):
powers_of_2_map[value] = member
if isinstance(member, _DeprecatedAlias):
continue

# Patching the member init call is around 100ns faster per call than
# using the default type.__call__ which would make us do the lookup
# in cls.__new__. Reason for this is that python will also always
# invoke cls.__init__ if we do this, so we end up with two function
# calls.
member = cls.__new__(cls, value)
member._name_ = name
member._value_ = value
setattr(cls, name, member)

name_to_member[name] = member
value_to_member.setdefault(value, member)
value_to_member[value] = member
member_names.append(name)

if not (value & value - 1):
powers_of_2_map[value] = member

all_bits = functools.reduce(operator.or_, value_to_member.keys())
all_bits_member = cls.__new__(cls, all_bits)
all_bits_member._name_ = None
Expand Down
4 changes: 1 addition & 3 deletions hikari/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ class Permissions(enums.Flag):
(or their owner's account in the case of bot users) and the guild owner.
"""

MANAGE_EMOJIS_AND_STICKERS = enums.deprecated(
MANAGE_GUILD_EXPRESSIONS, removal_version="2.0.0.dev123"
)
MANAGE_EMOJIS_AND_STICKERS = enums.deprecated(MANAGE_GUILD_EXPRESSIONS, removal_version="2.0.0.dev123")
"""Deprecated alias for MANAGE_GUILD_EXPRESSIONS."""

USE_APPLICATION_COMMANDS = 1 << 31
Expand Down
2 changes: 1 addition & 1 deletion tests/hikari/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def test_all_permissions(self):
all_perms = permissions.Permissions.all_permissions()

assert isinstance(all_perms, permissions.Permissions)
assert all_perms == 79164837199871
assert all_perms == 140737488355327

0 comments on commit c26e26d

Please sign in to comment.