Skip to content

Commit 06d72e6

Browse files
authored
Bump mypy to 0.800 and fix issues (#451)
1 parent a1bd5a0 commit 06d72e6

6 files changed

Lines changed: 11 additions & 17 deletions

File tree

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sphobjinv==2.0.1
2828
# TYPE CHECKING #
2929
#################
3030

31-
mypy==0.790
31+
mypy==0.800
3232

3333
#######################
3434
# DEPENDENCY CHECKING #

hikari/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class HTTPTimeoutSettings:
254254
def _(self, attrib: attr.Attribute[typing.Optional[float]], value: typing.Optional[float]) -> None:
255255
# This error won't occur until some time in the future where it will be annoying to
256256
# try and determine the root cause, so validate it NOW.
257-
if value is not None and (not isinstance(value, (float, int)) or value <= 0): # type: ignore[unreachable]
257+
if value is not None and (not isinstance(value, (float, int)) or value <= 0):
258258
raise ValueError(f"HTTPTimeoutSettings.{attrib.name} must be None, or a POSITIVE float/int")
259259

260260

@@ -325,7 +325,7 @@ class HTTPSettings:
325325
def _(self, _: attr.Attribute[typing.Optional[int]], value: typing.Optional[int]) -> None:
326326
# This error won't occur until some time in the future where it will be annoying to
327327
# try and determine the root cause, so validate it NOW.
328-
if value is not None and (not isinstance(value, int) or value <= 0): # type: ignore[unreachable]
328+
if value is not None and (not isinstance(value, int) or value <= 0):
329329
raise ValueError("http_settings.max_redirects must be None or a POSITIVE integer")
330330

331331
_ssl: typing.Union[bool, ssl_.SSLContext] = attr.ib(

hikari/impl/cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,10 +1411,10 @@ def _garbage_collect_message(
14111411
if guild_record:
14121412
self._garbage_collect_member(guild_record, message.object.member, decrement=1)
14131413

1414-
if message.object.referenced_message and message.object.referenced_message is not undefined.UNDEFINED:
1414+
if message.object.referenced_message:
14151415
self._garbage_collect_message(message.object.referenced_message, decrement=1)
14161416

1417-
if message.object.mentions.users and message.object.mentions.users is not undefined.UNDEFINED:
1417+
if message.object.mentions.users:
14181418
for user in message.object.mentions.users.values():
14191419
self._garbage_collect_user(user, decrement=1)
14201420

@@ -1489,7 +1489,7 @@ def _set_message(
14891489
mention_users = {user_id: self._set_user(user) for user_id, user in message.mentions.users.items()}
14901490

14911491
referenced_message: typing.Optional[cache_utility.RefCell[cache_utility.MessageData]] = None
1492-
if message.referenced_message and message.referenced_message is not undefined.UNDEFINED:
1492+
if message.referenced_message:
14931493
referenced_message = self._set_message(message.referenced_message)
14941494

14951495
if message.id not in self._referenced_messages and message.id not in self._message_entries:

hikari/impl/entity_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,8 @@ def serialize_embed( # noqa: C901
879879
# of debugging. The case that there are `None` should be detected immediately by
880880
# static type checkers, regardless.
881881

882-
name = str(field.name) if field.name is not None else None # type: ignore[unreachable]
883-
value = str(field.value) if field.value is not None else None # type: ignore[unreachable]
882+
name = str(field.name) if field.name is not None else None
883+
value = str(field.value) if field.value is not None else None
884884

885885
if name is None:
886886
raise TypeError(f"in embed.fields[{i}].name - cannot have `None`")

hikari/impl/rest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,8 @@ async def create_message(
10121012
embed = content
10131013
content = undefined.UNDEFINED
10141014

1015-
# os.PathLike is missing @runtime_checkable causing mypy to complain
10161015
elif undefined.count(attachment, attachments) == 2 and isinstance(
1017-
content, (files.Resource, files.RAWISH_TYPES, os.PathLike) # type: ignore[misc]
1016+
content, (files.Resource, files.RAWISH_TYPES, os.PathLike)
10181017
):
10191018
# Syntatic sugar, common mistake to accidentally send an attachment
10201019
# as the content, so lets detect this and fix it for the user. This
@@ -1414,9 +1413,8 @@ async def execute_webhook(
14141413
embed = content
14151414
content = undefined.UNDEFINED
14161415

1417-
# os.PathLike is missing @runtime_checkable causing mypy to complain
14181416
elif undefined.count(attachment, attachments) == 2 and isinstance(
1419-
content, (files.Resource, files.RAWISH_TYPES, os.PathLike) # type: ignore[misc]
1417+
content, (files.Resource, files.RAWISH_TYPES, os.PathLike)
14201418
):
14211419
# Syntatic sugar, common mistake to accidentally send an attachment
14221420
# as the content, so lets detect this and fix it for the user. This

hikari/internal/cache.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,7 @@ def build_from_entity(
754754
if not member and message.member:
755755
member = RefCell(MemberData.build_from_entity(message.member))
756756

757-
if (
758-
not referenced_message
759-
and message.referenced_message
760-
and message.referenced_message is not undefined.UNDEFINED
761-
):
757+
if not referenced_message and message.referenced_message:
762758
referenced_message = RefCell(MessageData.build_from_entity(message.referenced_message))
763759

764760
return cls(

0 commit comments

Comments
 (0)