Skip to content

Commit

Permalink
Bump mypy from 0.942 to 0.950 (#1147)
Browse files Browse the repository at this point in the history
Bumps [mypy](https:/python/mypy) from 0.942 to 0.950.
- [Release notes](https:/python/mypy/releases)
- [Commits](python/mypy@v0.942...v0.950)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Apr 28, 2022
1 parent 902b4a9 commit ed1f491
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sphobjinv==2.2.2
# TYPE CHECKING #
#################

mypy==0.942
mypy==0.950
pyright==1.1.241

#######################
Expand Down
4 changes: 2 additions & 2 deletions hikari/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DO NOT MANUALLY EDIT THIS FILE!
# This file was automatically generated by `nox -s generate-stubs`

from typing import Any
from _typeshed import Incomplete

from hikari import api as api
from hikari import applications as applications
Expand Down Expand Up @@ -101,4 +101,4 @@ from hikari.users import *
from hikari.voices import *
from hikari.webhooks import *

__all__: Any
__all__: Incomplete
40 changes: 18 additions & 22 deletions hikari/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,16 @@
import concurrent.futures
import datetime

_T = typing.TypeVar("_T", bound="EmbedResource[files.AsyncReader]")

AsyncReaderT = typing.TypeVar("AsyncReaderT", bound=files.AsyncReader)


@attr_extensions.with_copy
@attr.define(kw_only=True, weakref_slot=False)
class EmbedResource(files.Resource[AsyncReaderT]):
class EmbedResource(files.Resource[files.AsyncReader]):
"""A base type for any resource provided in an embed.
Resources can be downloaded and uploaded.
"""

resource: files.Resource[AsyncReaderT] = attr.field(repr=True)
resource: files.Resource[files.AsyncReader] = attr.field(repr=True)
"""The resource this object wraps around."""

@property
Expand Down Expand Up @@ -96,7 +92,7 @@ def stream(
*,
executor: typing.Optional[concurrent.futures.Executor] = None,
head_only: bool = False,
) -> files.AsyncReaderContextManager[AsyncReaderT]:
) -> files.AsyncReaderContextManager[files.AsyncReader]:
"""Produce a stream of data for the resource.
Parameters
Expand All @@ -114,10 +110,10 @@ def stream(


@attr.define(kw_only=True, weakref_slot=False)
class EmbedResourceWithProxy(EmbedResource[AsyncReaderT]):
class EmbedResourceWithProxy(EmbedResource):
"""Resource with a corresponding proxied element."""

proxy_resource: typing.Optional[files.Resource[AsyncReaderT]] = attr.field(default=None, repr=False)
proxy_resource: typing.Optional[files.Resource[files.AsyncReader]] = attr.field(default=None, repr=False)
"""The proxied version of the resource, or `builtins.None` if not present.
!!! note
Expand Down Expand Up @@ -163,12 +159,12 @@ class EmbedFooter:
text: typing.Optional[str] = attr.field(default=None, repr=True)
"""The footer text, or `builtins.None` if not present."""

icon: typing.Optional[EmbedResourceWithProxy[files.AsyncReader]] = attr.field(default=None, repr=True)
icon: typing.Optional[EmbedResourceWithProxy] = attr.field(default=None, repr=True)
"""The URL of the footer icon, or `builtins.None` if not present."""


@attr.define(hash=False, kw_only=True, weakref_slot=False)
class EmbedImage(EmbedResourceWithProxy[AsyncReaderT]):
class EmbedImage(EmbedResourceWithProxy):
"""Represents an embed image."""

height: typing.Optional[int] = attr.field(default=None, repr=False)
Expand All @@ -191,7 +187,7 @@ class EmbedImage(EmbedResourceWithProxy[AsyncReaderT]):


@attr.define(hash=False, kw_only=True, weakref_slot=False)
class EmbedVideo(EmbedResourceWithProxy[AsyncReaderT]):
class EmbedVideo(EmbedResourceWithProxy):
"""Represents an embed video.
!!! note
Expand Down Expand Up @@ -246,7 +242,7 @@ class EmbedAuthor:
This may be `builtins.None` if no hyperlink on the author's name is specified.
"""

icon: typing.Optional[EmbedResourceWithProxy[files.AsyncReader]] = attr.field(default=None, repr=False)
icon: typing.Optional[EmbedResourceWithProxy] = attr.field(default=None, repr=False)
"""The author's icon, or `builtins.None` if not present."""


Expand Down Expand Up @@ -315,9 +311,9 @@ def from_received_embed(
url: typing.Optional[str],
color: typing.Optional[colors.Color],
timestamp: typing.Optional[datetime.datetime],
image: typing.Optional[EmbedImage[files.AsyncReader]],
thumbnail: typing.Optional[EmbedImage[files.AsyncReader]],
video: typing.Optional[EmbedVideo[files.AsyncReader]],
image: typing.Optional[EmbedImage],
thumbnail: typing.Optional[EmbedImage],
video: typing.Optional[EmbedVideo],
author: typing.Optional[EmbedAuthor],
provider: typing.Optional[EmbedProvider],
footer: typing.Optional[EmbedFooter],
Expand Down Expand Up @@ -372,10 +368,10 @@ def __init__(
self.description = description
self.url = url
self._author: typing.Optional[EmbedAuthor] = None
self._image: typing.Optional[EmbedImage[files.AsyncReader]] = None
self._video: typing.Optional[EmbedVideo[files.AsyncReader]] = None
self._image: typing.Optional[EmbedImage] = None
self._video: typing.Optional[EmbedVideo] = None
self._provider: typing.Optional[EmbedProvider] = None
self._thumbnail: typing.Optional[EmbedImage[files.AsyncReader]] = None
self._thumbnail: typing.Optional[EmbedImage] = None
self._footer: typing.Optional[EmbedFooter] = None

# More boilerplate to allow this to be optional, but saves a useless list on every embed
Expand Down Expand Up @@ -605,7 +601,7 @@ def footer(self) -> typing.Optional[EmbedFooter]:
return self._footer

@property
def image(self) -> typing.Optional[EmbedImage[files.AsyncReader]]:
def image(self) -> typing.Optional[EmbedImage]:
"""Return the image set in the embed.
Will be `builtins.None` if not set.
Expand All @@ -619,7 +615,7 @@ def image(self) -> typing.Optional[EmbedImage[files.AsyncReader]]:
return self._image

@property
def thumbnail(self) -> typing.Optional[EmbedImage[files.AsyncReader]]:
def thumbnail(self) -> typing.Optional[EmbedImage]:
"""Return the thumbnail set in the embed.
Will be `builtins.None` if not set.
Expand All @@ -633,7 +629,7 @@ def thumbnail(self) -> typing.Optional[EmbedImage[files.AsyncReader]]:
return self._thumbnail

@property
def video(self) -> typing.Optional[EmbedVideo[files.AsyncReader]]:
def video(self) -> typing.Optional[EmbedVideo]:
"""Return the video to show in the embed.
Will be `builtins.None` if not set.
Expand Down
8 changes: 4 additions & 4 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ def deserialize_embed(self, payload: data_binding.JSONObject) -> embed_models.Em
timestamp = time.iso8601_datetime_string_to_datetime(payload["timestamp"]) if "timestamp" in payload else None
fields: typing.Optional[typing.List[embed_models.EmbedField]] = None

image: typing.Optional[embed_models.EmbedImage[files.AsyncReader]] = None
image: typing.Optional[embed_models.EmbedImage] = None
if (image_payload := payload.get("image")) and "url" in image_payload:
proxy = files.ensure_resource(image_payload["proxy_url"]) if "proxy_url" in image_payload else None
image = embed_models.EmbedImage(
Expand All @@ -1059,7 +1059,7 @@ def deserialize_embed(self, payload: data_binding.JSONObject) -> embed_models.Em
width=image_payload.get("width"),
)

thumbnail: typing.Optional[embed_models.EmbedImage[files.AsyncReader]] = None
thumbnail: typing.Optional[embed_models.EmbedImage] = None
if (thumbnail_payload := payload.get("thumbnail")) and "url" in thumbnail_payload:
proxy = files.ensure_resource(thumbnail_payload["proxy_url"]) if "proxy_url" in thumbnail_payload else None
thumbnail = embed_models.EmbedImage(
Expand All @@ -1069,7 +1069,7 @@ def deserialize_embed(self, payload: data_binding.JSONObject) -> embed_models.Em
width=thumbnail_payload.get("width"),
)

video: typing.Optional[embed_models.EmbedVideo[files.AsyncReader]] = None
video: typing.Optional[embed_models.EmbedVideo] = None
if (video_payload := payload.get("video")) and "url" in video_payload:
raw_proxy_url = video_payload.get("proxy_url")
video = embed_models.EmbedVideo(
Expand All @@ -1083,7 +1083,7 @@ def deserialize_embed(self, payload: data_binding.JSONObject) -> embed_models.Em
if provider_payload := payload.get("provider"):
provider = embed_models.EmbedProvider(name=provider_payload.get("name"), url=provider_payload.get("url"))

icon: typing.Optional[embed_models.EmbedResourceWithProxy[files.AsyncReader]]
icon: typing.Optional[embed_models.EmbedResourceWithProxy]
author: typing.Optional[embed_models.EmbedAuthor] = None
if author_payload := payload.get("author"):
icon = None
Expand Down

0 comments on commit ed1f491

Please sign in to comment.