nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: hikari-py/hikari
Pull request #1207 (2022-07-09 03:55:55)

Remove case of bang (`!`) from `Member.mention` property
### Summary
<!-- Small summary of the merge request -->
Discord mentions should not have the `!` bang anymore per deprecation by Discord.

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1207.breaking.md b/changes/1207.breaking.md
new file mode 100644
index 00000000..3b72d741
--- /dev/null
+++ b/changes/1207.breaking.md
@@ -0,0 +1,1 @@
+Removed case of `Member.mention` returning bang (`!`) mention, as it is deprecated by Discord.
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 79cf220d..784dd601 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -29,7 +29,7 @@ sphobjinv==2.2.2
 #################
 
 mypy==0.961
-pyright==1.1.259
+pyright==1.1.260
 
 #######################
 # DEPENDENCY CHECKING #
diff --git a/hikari/guilds.py b/hikari/guilds.py
index 0155f078..fa75c4ed 100644
--- a/hikari/guilds.py
+++ b/hikari/guilds.py
@@ -484,28 +484,7 @@ def is_system(self) -> bool:
 
     @property
     def mention(self) -> str:
-        """Return a raw mention string for the given member.
-
-        If the member has a known nickname, we always return
-        a bang ("`!`") before the ID part of the mention string. This
-        mimics the behaviour Discord clients tend to provide.
-
-        Example
-        -------
-
-        ```py
-        >>> some_member_without_nickname.mention
-        '<@123456789123456789>'
-        >>> some_member_with_nickname.mention
-        '<@!123456789123456789>'
-        ```
-
-        Returns
-        -------
-        builtins.str
-            The mention string to use.
-        """
-        return f"<@!{self.id}>" if self.nickname is not None else self.user.mention
+        return self.user.mention
 
     def communication_disabled_until(self) -> typing.Optional[datetime.datetime]:
         """Return when the timeout for this member ends.


Test patch:
diff --git a/tests/hikari/test_guilds.py b/tests/hikari/test_guilds.py
index 551481e1..b3ff77c3 100644
--- a/tests/hikari/test_guilds.py
+++ b/tests/hikari/test_guilds.py
@@ -485,11 +485,7 @@ def test_display_name_property_when_no_nickname(self, model, mock_user):
         model.nickname = None
         assert model.display_name is mock_user.username
 
-    def test_mention_property_when_nickname(self, model):
-        assert model.mention == "<@!123>"
-
-    def test_mention_property_when_no_nickname(self, model, mock_user):
-        model.nickname = None
+    def test_mention_property(self, model, mock_user):
         assert model.mention == mock_user.mention
 
     def test_get_guild(self, model):
Repository: hikari-py/hikari
Pull request #1259 (2022-08-18 15:26:04)

Fix endpoint used in reposition_channels
### Summary
<!-- Small summary of the merge request -->
`reposition_channels` currently doesn't work, as it uses the `POST_GUILD_CHANNELS` route instead
 of the `PATCH_GUILD_CHANNELS` route.

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1259.bugfix.md b/changes/1259.bugfix.md
new file mode 100644
index 00000000..343524de
--- /dev/null
+++ b/changes/1259.bugfix.md
@@ -0,0 +1,1 @@
+Fix `reposition_channels` to use the correct route.
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index 20ff9441..3504f7d0 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -2585,7 +2585,7 @@ async def reposition_channels(
         guild: snowflakes.SnowflakeishOr[guilds.PartialGuild],
         positions: typing.Mapping[int, snowflakes.SnowflakeishOr[channels_.GuildChannel]],
     ) -> None:
-        route = routes.POST_GUILD_CHANNELS.compile(guild=guild)
+        route = routes.PATCH_GUILD_CHANNELS.compile(guild=guild)
         body = [{"id": str(int(channel)), "position": pos} for pos, channel in positions.items()]
         await self._request(route, json=body)
 


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 83abb268..61e5440d 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -4031,7 +4031,7 @@ async def test__create_guild_channel(self, rest_client):
         )
 
     async def test_reposition_channels(self, rest_client):
-        expected_route = routes.POST_GUILD_CHANNELS.compile(guild=123)
+        expected_route = routes.PATCH_GUILD_CHANNELS.compile(guild=123)
         expected_json = [{"id": "456", "position": 1}, {"id": "789", "position": 2}]
         rest_client._request = mock.AsyncMock()
Repository: hikari-py/hikari
Pull request #1274 (2022-08-28 05:20:01)

Include name_localizations on MenuBuilder.create
Signed-off-by: Lucina <lucina@lmbyrne.dev>

### Summary
<!-- Small summary of the merge request -->

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [ ] I have run `nox` and all the pipelines have passed.
- [ ] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/hikari/impl/special_endpoints.py b/hikari/impl/special_endpoints.py
index b4d0c3cc..6cb801b2 100644
--- a/hikari/impl/special_endpoints.py
+++ b/hikari/impl/special_endpoints.py
@@ -1258,6 +1258,7 @@ async def create(
             self._type,
             self._name,
             guild=guild,
+            name_localizations=self._name_localizations,
             default_member_permissions=self._default_member_permissions,
             dm_enabled=self._is_dm_enabled,
         )


Test patch:
diff --git a/tests/hikari/impl/test_special_endpoints.py b/tests/hikari/impl/test_special_endpoints.py
index f9d8fadb..c1e1e1bc 100644
--- a/tests/hikari/impl/test_special_endpoints.py
+++ b/tests/hikari/impl/test_special_endpoints.py
@@ -808,6 +808,7 @@ async def test_create(self):
         builder = (
             special_endpoints.ContextMenuCommandBuilder(commands.CommandType.USER, "we are number")
             .set_default_member_permissions(permissions.Permissions.BAN_MEMBERS)
+            .set_name_localizations({"meow": "nyan"})
             .set_is_dm_enabled(True)
         )
         mock_rest = mock.AsyncMock()
@@ -821,6 +822,7 @@ async def test_create(self):
             builder.name,
             guild=undefined.UNDEFINED,
             default_member_permissions=permissions.Permissions.BAN_MEMBERS,
+            name_localizations={"meow": "nyan"},
             dm_enabled=True,
         )
 
@@ -829,6 +831,7 @@ async def test_create_with_guild(self):
         builder = (
             special_endpoints.ContextMenuCommandBuilder(commands.CommandType.USER, "we are number")
             .set_default_member_permissions(permissions.Permissions.BAN_MEMBERS)
+            .set_name_localizations({"en-ghibli": "meow"})
             .set_is_dm_enabled(True)
         )
         mock_rest = mock.AsyncMock()
@@ -842,6 +845,7 @@ async def test_create_with_guild(self):
             builder.name,
             guild=765234123,
             default_member_permissions=permissions.Permissions.BAN_MEMBERS,
+            name_localizations={"en-ghibli": "meow"},
             dm_enabled=True,
         )
Repository: hikari-py/hikari
Pull request #1334 (2022-10-28 16:24:46)

Add hikari.Permissions.MANAGE_EVENT
### Summary
<!-- Small summary of the merge request -->
Add the MANAGE_EVENT permission, no idea how this was missed.

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [ ] I have run `nox` and all the pipelines have passed.
- [ ] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1334.feature.md b/changes/1334.feature.md
new file mode 100644
index 00000000..cd6bbbb0
--- /dev/null
+++ b/changes/1334.feature.md
@@ -0,0 +1,1 @@
+Add `MANAGE_EVENTS` permission to `hikari.Permissions`
diff --git a/hikari/permissions.py b/hikari/permissions.py
index 86808fb6..ef8f06a6 100644
--- a/hikari/permissions.py
+++ b/hikari/permissions.py
@@ -246,6 +246,9 @@ class Permissions(enums.Flag):
         without warning.
     """
 
+    MANAGE_EVENTS = 1 << 33
+    """Allows for creating, editing, and deleting scheduled events	"""
+
     MANAGE_THREADS = 1 << 34
     """Allows for deleting and archiving threads, and viewing all private threads.
 


Test patch:
diff --git a/tests/hikari/test_permissions.py b/tests/hikari/test_permissions.py
index 912f466e..fd96424b 100644
--- a/tests/hikari/test_permissions.py
+++ b/tests/hikari/test_permissions.py
@@ -27,4 +27,4 @@ def test_all_permissions(self):
         all_perms = permissions.Permissions.all_permissions()
 
         assert isinstance(all_perms, permissions.Permissions)
-        assert all_perms == 2190433320959
+        assert all_perms == 2199023255551
Repository: hikari-py/hikari
Pull request #1355 (2022-11-10 22:23:42)

Add new ACTIVE_DEVELOPER flag to UserFlags
### Summary
Adds the new [Active Developer](https://support-dev.discord.com/hc/en-us/articles/10113997751447) badge to the list of available user flags.

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

<!--
### Related issues
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1355.feature.md b/changes/1355.feature.md
new file mode 100644
index 00000000..bd19256e
--- /dev/null
+++ b/changes/1355.feature.md
@@ -0,0 +1,1 @@
+Add new `UserFlag.ACTIVE_DEVELOPER`.
diff --git a/hikari/users.py b/hikari/users.py
index 6b15a39e..f4d7c566 100644
--- a/hikari/users.py
+++ b/hikari/users.py
@@ -102,6 +102,9 @@ class UserFlag(enums.Flag):
     BOT_HTTP_INTERACTIONS = 1 << 19
     """Bot uses only HTTP interactions and is shown in the active member list."""
 
+    ACTIVE_DEVELOPER = 1 << 22
+    """User is an active bot developer."""
+
 
 @typing.final
 class PremiumType(int, enums.Enum):


Test patch:
diff --git a/tests/hikari/impl/test_entity_factory.py b/tests/hikari/impl/test_entity_factory.py
index d29aaa7f..decdc3a3 100644
--- a/tests/hikari/impl/test_entity_factory.py
+++ b/tests/hikari/impl/test_entity_factory.py
@@ -216,7 +216,7 @@ def user_payload():
         "discriminator": "6127",
         "bot": True,
         "system": True,
-        "public_flags": int(user_models.UserFlag.EARLY_VERIFIED_DEVELOPER),
+        "public_flags": int(user_models.UserFlag.EARLY_VERIFIED_DEVELOPER | user_models.UserFlag.ACTIVE_DEVELOPER),
     }
 
 
@@ -6324,7 +6324,7 @@ def test_deserialize_user(self, entity_factory_impl, mock_app, user_payload):
         assert user.discriminator == "6127"
         assert user.is_bot is True
         assert user.is_system is True
-        assert user.flags == user_models.UserFlag.EARLY_VERIFIED_DEVELOPER
+        assert user.flags == user_models.UserFlag.EARLY_VERIFIED_DEVELOPER | user_models.UserFlag.ACTIVE_DEVELOPER
         assert isinstance(user, user_models.UserImpl)
 
     def test_deserialize_user_with_unset_fields(self, entity_factory_impl, mock_app, user_payload):
Repository: hikari-py/hikari
Pull request #1435 (2022-12-31 10:31:00)

Actually start bucket manager gc
### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.



Patch:
diff --git a/changes/1435.bugfix.md b/changes/1435.bugfix.md
new file mode 100644
index 00000000..82c45ca6
--- /dev/null
+++ b/changes/1435.bugfix.md
@@ -0,0 +1,1 @@
+Start GC of bucket manager when creating a rest client.
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index d296e892..e6ca8364 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -449,8 +449,10 @@ def build(
             trust_env=proxy_settings.trust_env,
         )
         _LOGGER.log(ux.TRACE, "acquired new aiohttp client session")
+        buckets = buckets_impl.RESTBucketManager(max_rate_limit)
+        buckets.start()
         return _LiveAttributes(
-            buckets=buckets_impl.RESTBucketManager(max_rate_limit),
+            buckets=buckets,
             client_session=client_session,
             closed_event=asyncio.Event(),
             global_rate_limit=rate_limits.ManualRateLimiter(),


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 2af8b2f9..9d914ac0 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -320,6 +320,7 @@ def test_build(self):
         assert attributes.tcp_connector is create_tcp_connector.return_value
 
         bucket_manager.assert_called_once_with(123.321)
+        bucket_manager.return_value.start.assert_called_once_with()
         create_tcp_connector.assert_called_once_with(mock_settings)
         create_client_session.assert_called_once_with(
             connector=create_tcp_connector.return_value,
Repository: hikari-py/hikari
Pull request #1545 (2023-03-14 09:19:32)

Read the banner with `utf-8` encoding
### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.


Patch:
diff --git a/changes/1545.bugfix.md b/changes/1545.bugfix.md
new file mode 100644
index 00000000..c9932bd0
--- /dev/null
+++ b/changes/1545.bugfix.md
@@ -0,0 +1,1 @@
+Open `banner.txt`s with `utf-8` encoding explicitly.
diff --git a/hikari/internal/ux.py b/hikari/internal/ux.py
index 86108cb4..131816d3 100644
--- a/hikari/internal/ux.py
+++ b/hikari/internal/ux.py
@@ -240,10 +240,10 @@ def init_logging(
 
 def _read_banner(package: str) -> str:
     if sys.version_info >= (3, 9):
-        with importlib.resources.files(package).joinpath("banner.txt").open("r") as fp:
+        with importlib.resources.files(package).joinpath("banner.txt").open("r", encoding="utf-8") as fp:
             return fp.read()
     else:
-        return importlib.resources.read_text(package, "banner.txt")
+        return importlib.resources.read_text(package, "banner.txt", encoding="utf-8")
 
 
 def print_banner(


Test patch:
diff --git a/tests/hikari/internal/test_ux.py b/tests/hikari/internal/test_ux.py
index eb6bb019..02b39ac9 100644
--- a/tests/hikari/internal/test_ux.py
+++ b/tests/hikari/internal/test_ux.py
@@ -233,13 +233,15 @@ class MockTraversable:
             joint_path = None
             open_mode = None
             mock_file = None
+            open_encoding = None
 
             def joinpath(self, path):
                 self.joint_path = path
                 return self
 
-            def open(self, mode):
+            def open(self, mode, encoding):
                 self.open_mode = mode
+                self.open_encoding = encoding
                 return self.mock_file
 
         traversable = MockTraversable()
@@ -253,6 +255,7 @@ def open(self, mode):
         read_text.assert_called_once_with("hikaru")
         assert traversable.joint_path == "banner.txt"
         assert traversable.open_mode == "r"
+        assert traversable.open_encoding == "utf-8"
         assert traversable.mock_file.context_entered == 1
         assert traversable.mock_file.context_exited == 1
 
@@ -261,7 +264,7 @@ def test_when_below_3_9(self):
             with mock.patch.object(importlib.resources, "read_text") as read_text:
                 assert ux._read_banner("hikaru") is read_text.return_value
 
-        read_text.assert_called_once_with("hikaru", "banner.txt")
+        read_text.assert_called_once_with("hikaru", "banner.txt", encoding="utf-8")
 
 
 class TestPrintBanner:
Repository: hikari-py/hikari
Pull request #1562 (2023-03-25 18:06:16)

Implement LazyIterator.flatten method
### Summary
<!-- Small summary of the merge request -->

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [ ] I have run `nox` and all the pipelines have passed.
- [ ] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1562.feature.md b/changes/1562.feature.md
new file mode 100644
index 00000000..a1899d2d
--- /dev/null
+++ b/changes/1562.feature.md
@@ -0,0 +1,1 @@
+`hikari.iterators.LazyIterator.flatten` method for flattening a lazy iterator of synchronous iterables.
diff --git a/hikari/iterators.py b/hikari/iterators.py
index cec73362..21a7ecdf 100644
--- a/hikari/iterators.py
+++ b/hikari/iterators.py
@@ -639,6 +639,10 @@ def iter_mentioned_users(message: hikari.Message) -> typing.Iterable[Snowflake]:
         """
         return _FlatMapLazyIterator(self, flattener)
 
+    def flatten(self: LazyIterator[typing.Iterable[AnotherValueT]]) -> LazyIterator[AnotherValueT]:
+        """Flatten an async iterator of iterables."""
+        return self.flat_map(_flatten)
+
     def awaiting(self, window_size: int = 10) -> LazyIterator[ValueT]:
         """Await each item concurrently in a fixed size window.
 
@@ -733,6 +737,10 @@ def __next__(self) -> typing.NoReturn:
             ) from None
 
 
+def _flatten(value: ValueT) -> ValueT:
+    return value
+
+
 class BufferedLazyIterator(typing.Generic[ValueT], LazyIterator[ValueT], abc.ABC):
     """A special kind of lazy iterator that is used by internal components.
 


Test patch:
diff --git a/tests/hikari/test_iterators.py b/tests/hikari/test_iterators.py
index 9a0c61cb..11067d98 100644
--- a/tests/hikari/test_iterators.py
+++ b/tests/hikari/test_iterators.py
@@ -33,3 +33,9 @@ def lazy_iterator(self):
     def test_asynchronous_only(self, lazy_iterator):
         with pytest.raises(TypeError, match="is async-only, did you mean 'async for' or `anext`?"):
             next(lazy_iterator)
+
+    @pytest.mark.asyncio()
+    async def test_flatten(self):
+        iterator = iterators.FlatLazyIterator([[123, 321, 4352, 123], [], [12343123, 4234432], [543123123]])
+
+        assert await iterator.flatten() == [123, 321, 4352, 123, 12343123, 4234432, 543123123]
Repository: hikari-py/hikari
Pull request #1720 (2023-09-22 19:17:40)

Fix ["revoked"] KeyError for `deserialize_own_connection`
### Summary
<!-- Small summary of the merge request -->

### Checklist
<!-- Make sure to tick all the following boxes by putting an `x` in between (like this `[x]`) -->
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.

### Related issues
<!--
To mention an issue use `#issue-id` and to mention a merge request use `!merge-request-id`
To close/fix an issue use `Close #issue-id` or `Fix #issue-id` (depending on the merge request)
-->



Patch:
diff --git a/changes/1720.bugfix.md b/changes/1720.bugfix.md
new file mode 100644
index 00000000..8fd9ed81
--- /dev/null
+++ b/changes/1720.bugfix.md
@@ -0,0 +1,1 @@
+Fix optional connection "revoked" field KeyError when fetching connections.
diff --git a/hikari/impl/entity_factory.py b/hikari/impl/entity_factory.py
index b5358e2a..a5f6cebf 100644
--- a/hikari/impl/entity_factory.py
+++ b/hikari/impl/entity_factory.py
@@ -572,7 +572,7 @@ def deserialize_own_connection(self, payload: data_binding.JSONObject) -> applic
             id=payload["id"],
             name=payload["name"],
             type=payload["type"],
-            is_revoked=payload["revoked"],
+            is_revoked=payload.get("revoked", False),
             integrations=integrations,
             is_verified=payload["verified"],
             is_friend_sync_enabled=payload["friend_sync"],


Test patch:
diff --git a/tests/hikari/impl/test_entity_factory.py b/tests/hikari/impl/test_entity_factory.py
index 47fd133c..35d07ed1 100644
--- a/tests/hikari/impl/test_entity_factory.py
+++ b/tests/hikari/impl/test_entity_factory.py
@@ -872,8 +872,11 @@ def test_deserialize_own_connection(self, entity_factory_impl, own_connection_pa
         assert own_connection.visibility == application_models.ConnectionVisibility.NONE
         assert isinstance(own_connection, application_models.OwnConnection)
 
-    def test_deserialize_own_connection_when_integrations_is_None(self, entity_factory_impl, own_connection_payload):
+    def test_deserialize_own_connection_with_nullable_and_optional_fields(
+        self, entity_factory_impl, own_connection_payload
+    ):
         del own_connection_payload["integrations"]
+        del own_connection_payload["revoked"]
         own_connection = entity_factory_impl.deserialize_own_connection(own_connection_payload)
         assert own_connection.id == "2513849648abc"
         assert own_connection.name == "FS"