Repository: hikari-py/hikari
Pull request #707 (2021-07-27 14:35:33)

Fix incorrect JSON arguments in edit_guild
### 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.


FasterSpeeding: broken tests
Tmpod: Same test still failing? (not well versed in GH's pipelines)

Patch:
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 17d48fb3..23444aa1 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -41,4 +41,4 @@ safety~=1.10.3
 #############
 
 black==21.7b0
-isort==5.9.2
+isort==5.9.3
diff --git a/examples/image_resources/image_resources.py b/examples/image_resources/image_resources.py
index 048925b7..3a0bc95c 100644
--- a/examples/image_resources/image_resources.py
+++ b/examples/image_resources/image_resources.py
@@ -69,10 +69,10 @@ async def inspect_image(event: hikari.GuildMessageCreateEvent, what: str) -> Non
             await event.message.respond("Guild is missing from the cache :(")
             return
 
-        if guild.icon_url is None:
+        if (icon_url := guild.icon_url) is None:
             await event.message.respond("This guild doesn't have an icon")
         else:
-            await event.message.respond("Guild icon", attachment=guild.icon_url)
+            await event.message.respond("Guild icon", attachment=icon_url)
 
     # Show the image for the given emoji if there is some content present:
     elif what:
diff --git a/hikari/__init__.pyi b/hikari/__init__.pyi
index 66e4a9e6..566b8da5 100644
--- a/hikari/__init__.pyi
+++ b/hikari/__init__.pyi
@@ -1,5 +1,33 @@
-# This file was generated by `nox -s generate-stubs`. Do not manually edit this file!
+# DO NOT MANUALLY EDIT THIS FILE!
+# This file was automatically generated by `nox -s generate-stubs`
 
+from typing import Any
+
+from hikari._about import __author__ as __author__
+from hikari._about import __ci__ as __ci__
+from hikari._about import __copyright__ as __copyright__
+from hikari._about import __discord_invite__ as __discord_invite__
+from hikari._about import __docs__ as __docs__
+from hikari._about import __email__ as __email__
+from hikari._about import __issue_tracker__ as __issue_tracker__
+from hikari._about import __license__ as __license__
+from hikari._about import __url__ as __url__
+from hikari._about import __version__ as __version__
+from hikari.applications import Application as Application
+from hikari.applications import ApplicationFlags as ApplicationFlags
+from hikari.applications import AuthorizationApplication as AuthorizationApplication
+from hikari.applications import AuthorizationInformation as AuthorizationInformation
+from hikari.applications import ConnectionVisibility as ConnectionVisibility
+from hikari.applications import OAuth2AuthorizationToken as OAuth2AuthorizationToken
+from hikari.applications import OAuth2ImplicitToken as OAuth2ImplicitToken
+from hikari.applications import OAuth2Scope as OAuth2Scope
+from hikari.applications import OwnConnection as OwnConnection
+from hikari.applications import OwnGuild as OwnGuild
+from hikari.applications import PartialOAuth2Token as PartialOAuth2Token
+from hikari.applications import Team as Team
+from hikari.applications import TeamMember as TeamMember
+from hikari.applications import TeamMembershipState as TeamMembershipState
+from hikari.applications import TokenType as TokenType
 from hikari.audit_logs import *
 from hikari.channels import *
 from hikari.colors import *
@@ -9,7 +37,19 @@ from hikari.embeds import *
 from hikari.emojis import *
 from hikari.errors import *
 from hikari.events import *
+from hikari.files import URL as URL
+from hikari.files import Bytes as Bytes
+from hikari.files import File as File
+from hikari.files import LazyByteIteratorish as LazyByteIteratorish
+from hikari.files import Pathish as Pathish
+from hikari.files import Rawish as Rawish
+from hikari.files import Resourceish as Resourceish
 from hikari.guilds import *
+from hikari.impl.bot import BotApp as BotApp
+from hikari.impl.bot import GatewayBot as GatewayBot
+from hikari.impl.rest import ClientCredentialsStrategy as ClientCredentialsStrategy
+from hikari.impl.rest import RESTApp as RESTApp
+from hikari.impl.rest_bot import RESTBot as RESTBot
 from hikari.intents import *
 from hikari.interactions import *
 from hikari.invites import *
@@ -18,19 +58,21 @@ from hikari.messages import *
 from hikari.permissions import *
 from hikari.presences import *
 from hikari.sessions import *
+from hikari.snowflakes import SearchableSnowflakeish as SearchableSnowflakeish
+from hikari.snowflakes import SearchableSnowflakeishOr as SearchableSnowflakeishOr
+from hikari.snowflakes import Snowflake as Snowflake
+from hikari.snowflakes import Snowflakeish as Snowflakeish
+from hikari.snowflakes import SnowflakeishOr as SnowflakeishOr
+from hikari.snowflakes import SnowflakeishSequence as SnowflakeishSequence
+from hikari.snowflakes import Unique as Unique
 from hikari.templates import *
 from hikari.traits import *
+from hikari.undefined import UNDEFINED as UNDEFINED
+from hikari.undefined import UndefinedNoneOr as UndefinedNoneOr
+from hikari.undefined import UndefinedOr as UndefinedOr
+from hikari.undefined import UndefinedType as UndefinedType
 from hikari.users import *
 from hikari.voices import *
 from hikari.webhooks import *
-from hikari._about import __author__ as __author__, __ci__ as __ci__, __copyright__ as __copyright__, __discord_invite__ as __discord_invite__, __docs__ as __docs__, __email__ as __email__, __issue_tracker__ as __issue_tracker__, __license__ as __license__, __url__ as __url__, __version__ as __version__
-from hikari.applications import Application as Application, ApplicationFlags as ApplicationFlags, AuthorizationApplication as AuthorizationApplication, AuthorizationInformation as AuthorizationInformation, ConnectionVisibility as ConnectionVisibility, OAuth2AuthorizationToken as OAuth2AuthorizationToken, OAuth2ImplicitToken as OAuth2ImplicitToken, OAuth2Scope as OAuth2Scope, OwnConnection as OwnConnection, OwnGuild as OwnGuild, PartialOAuth2Token as PartialOAuth2Token, Team as Team, TeamMember as TeamMember, TeamMembershipState as TeamMembershipState, TokenType as TokenType
-from hikari.files import Bytes as Bytes, File as File, LazyByteIteratorish as LazyByteIteratorish, Pathish as Pathish, Rawish as Rawish, Resourceish as Resourceish, URL as URL
-from hikari.impl.bot import BotApp as BotApp, GatewayBot as GatewayBot
-from hikari.impl.rest import ClientCredentialsStrategy as ClientCredentialsStrategy, RESTApp as RESTApp
-from hikari.impl.rest_bot import RESTBot as RESTBot
-from hikari.snowflakes import SearchableSnowflakeish as SearchableSnowflakeish, SearchableSnowflakeishOr as SearchableSnowflakeishOr, Snowflake as Snowflake, Snowflakeish as Snowflakeish, SnowflakeishOr as SnowflakeishOr, SnowflakeishSequence as SnowflakeishSequence, Unique as Unique
-from hikari.undefined import UNDEFINED as UNDEFINED, UndefinedNoneOr as UndefinedNoneOr, UndefinedOr as UndefinedOr, UndefinedType as UndefinedType
-from typing import Any
 
 __all__: Any
diff --git a/hikari/events/__init__.pyi b/hikari/events/__init__.pyi
index ffe4c7f3..81c9e2d6 100644
--- a/hikari/events/__init__.pyi
+++ b/hikari/events/__init__.pyi
@@ -1,5 +1,8 @@
-# This file was generated by `nox -s generate-stubs`. Do not manually edit this file!
+# DO NOT MANUALLY EDIT THIS FILE!
+# This file was automatically generated by `nox -s generate-stubs`
 
+from hikari.events.base_events import Event as Event
+from hikari.events.base_events import ExceptionEvent as ExceptionEvent
 from hikari.events.channel_events import *
 from hikari.events.guild_events import *
 from hikari.events.interaction_events import *
@@ -12,4 +15,3 @@ from hikari.events.shard_events import *
 from hikari.events.typing_events import *
 from hikari.events.user_events import *
 from hikari.events.voice_events import *
-from hikari.events.base_events import Event as Event, ExceptionEvent as ExceptionEvent
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index 2af2f9d5..7125d6de 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -2194,8 +2194,8 @@ async def edit_guild(
         route = routes.PATCH_GUILD.compile(guild=guild)
         body = data_binding.JSONObjectBuilder()
         body.put("name", name)
-        body.put("verification", verification_level)
-        body.put("notifications", default_message_notifications)
+        body.put("verification_level", verification_level)
+        body.put("default_message_notifications", default_message_notifications)
         body.put("explicit_content_filter", explicit_content_filter_level)
         body.put("afk_timeout", afk_timeout, conversion=time.timespan_to_int)
         body.put("preferred_locale", preferred_locale, conversion=str)
diff --git a/hikari/interactions/__init__.pyi b/hikari/interactions/__init__.pyi
index 73889985..3d1171ed 100644
--- a/hikari/interactions/__init__.pyi
+++ b/hikari/interactions/__init__.pyi
@@ -1,4 +1,5 @@
-# This file was generated by `nox -s generate-stubs`. Do not manually edit this file!
+# DO NOT MANUALLY EDIT THIS FILE!
+# This file was automatically generated by `nox -s generate-stubs`
 
 from hikari.interactions.bases import *
 from hikari.interactions.commands import *
diff --git a/pipelines/format.nox.py b/pipelines/format.nox.py
index fc92685a..ec70992f 100644
--- a/pipelines/format.nox.py
+++ b/pipelines/format.nox.py
@@ -19,7 +19,7 @@
 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
-"""Black code-style jobs."""
+"""Code-style jobs."""
 import os
 import shutil
 import subprocess
diff --git a/pipelines/mypy.nox.py b/pipelines/mypy.nox.py
index 31035236..d430dfb6 100644
--- a/pipelines/mypy.nox.py
+++ b/pipelines/mypy.nox.py
@@ -47,14 +47,16 @@ def generate_stubs(session: nox.Session) -> None:
 def _generate_stubs(session: nox.Session) -> None:
     session.run("stubgen", *STUBGEN_GENERATE, "-o", ".", "--include-private", "--no-import")
 
-    for path in STUBGEN_GENERATE:
-        # We add "i" because we turn ".py" into ".pyi"
-        stub_path = path + "i"
+    stub_paths = [path + "i" for path in STUBGEN_GENERATE]
 
+    session.run("isort", *stub_paths)
+    session.run("black", *stub_paths)
+
+    for stub_path in stub_paths:
         with open(stub_path, "r") as fp:
             content = fp.read()
 
         with open(stub_path, "w") as fp:
-            fp.write(
-                "# This file was generated by `nox -s generate-stubs`. Do not manually edit this file!\n\n" + content
-            )
+            fp.write("# DO NOT MANUALLY EDIT THIS FILE!\n")
+            fp.write("# This file was automatically generated by `nox -s generate-stubs`\n\n")
+            fp.write(content)


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 11adee3b..d765d128 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -2443,8 +2443,8 @@ async def test_edit_guild(self, rest_client, file_resource):
         expected_route = routes.PATCH_GUILD.compile(guild=123)
         expected_json = {
             "name": "hikari",
-            "verification": 3,
-            "notifications": 1,
+            "verification_level": 3,
+            "default_message_notifications": 1,
             "explicit_content_filter": 1,
             "afk_timeout": 60,
             "preferred_locale": "en-UK",
@@ -2487,8 +2487,8 @@ async def test_edit_guild_when_images_are_None(self, rest_client):
         expected_route = routes.PATCH_GUILD.compile(guild=123)
         expected_json = {
             "name": "hikari",
-            "verification": 3,
-            "notifications": 1,
+            "verification_level": 3,
+            "default_message_notifications": 1,
             "explicit_content_filter": 1,
             "afk_timeout": 60,
             "preferred_locale": "en-UK",