From e5b609601cd3fb5a573c0ea1653fdf13d5604032 Mon Sep 17 00:00:00 2001 From: probablyjassin Date: Sat, 2 Nov 2024 11:05:09 +0100 Subject: [PATCH 1/7] replaced NewType cached_property with functools' cached_property to fix type annotations for context atrributes --- discord/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/utils.py b/discord/utils.py index fbcf9c1f31..29921bf5b8 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -151,7 +151,7 @@ def __get__(self, instance, owner): class _RequestLike(Protocol): headers: Mapping[str, Any] - cached_property = NewType("cached_property", property) + cached_property = functools.cached_property P = ParamSpec("P") From 57b24044128a929c13548b911630c67cf5d2102f Mon Sep 17 00:00:00 2001 From: probablyjassin Date: Sat, 2 Nov 2024 11:21:36 +0100 Subject: [PATCH 2/7] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d77dee89d3..7e41d27c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2611](https://github.com/Pycord-Development/pycord/pull/2611)) - Fixed `TypeError` when passing `skus` parameter in `Client.entitlements()`. ([#2627](https://github.com/Pycord-Development/pycord/issues/2627)) +- Fixed type annotations for attributes of `context` + ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) ### Changed From a9bd1b5d41cc178da46edef76525fb077984f209 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 10:25:11 +0000 Subject: [PATCH 3/7] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/discord/utils.py b/discord/utils.py index 29921bf5b8..9d71f76cd8 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -56,7 +56,6 @@ Iterator, Literal, Mapping, - NewType, Protocol, Sequence, TypeVar, From 0f5d52c522072d1f67d0d30a79f6207b187c0cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A4ssin=20Aouani?= <123012687+probablyjassin@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:18:58 +0100 Subject: [PATCH 4/7] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paillat Signed-off-by: Jässin Aouani <123012687+probablyjassin@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e41d27c26..3646deb238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2611](https://github.com/Pycord-Development/pycord/pull/2611)) - Fixed `TypeError` when passing `skus` parameter in `Client.entitlements()`. ([#2627](https://github.com/Pycord-Development/pycord/issues/2627)) -- Fixed type annotations for attributes of `context` ++ Fixed type annotations of cached properties ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) ### Changed From 735de88ef5cad85dd7187f892a1f0c921071e62c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 11:19:21 +0000 Subject: [PATCH 5/7] style(pre-commit): auto fixes from pre-commit.com hooks --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3646deb238..9596baca24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2611](https://github.com/Pycord-Development/pycord/pull/2611)) - Fixed `TypeError` when passing `skus` parameter in `Client.entitlements()`. ([#2627](https://github.com/Pycord-Development/pycord/issues/2627)) -+ Fixed type annotations of cached properties + +* Fixed type annotations of cached properties ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) ### Changed From a750a6b051119f3eb725ebd99836109e70db17bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A4ssin=20Aouani?= <123012687+probablyjassin@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:45:07 +0100 Subject: [PATCH 6/7] implement @DA-344's recommendation: cached_property = property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've tested this with a project of mine and it fixes the types on attributes of ApplicationContext without breaking anything else Signed-off-by: Jässin Aouani <123012687+probablyjassin@users.noreply.github.com> --- discord/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/utils.py b/discord/utils.py index 9d71f76cd8..c04ef0b0bd 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -150,7 +150,7 @@ def __get__(self, instance, owner): class _RequestLike(Protocol): headers: Mapping[str, Any] - cached_property = functools.cached_property + cached_property = property P = ParamSpec("P") From 6a35c68f1be8d7ea908e887d8b512a13b8cf6dbb Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:22:04 +0300 Subject: [PATCH 7/7] Update CHANGELOG.md Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c81fb7285..1bda9a0ecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,8 +62,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2624](https://github.com/Pycord-Development/pycord/pull/2624)) - Fixed `AttributeError` when accessing `Member.guild_permissions` for user installed apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650)) - -* Fixed type annotations of cached properties +- Fixed type annotations of cached properties. ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) ### Changed