From 0c68e5f592e356f8251faff0ec8dd9f8cacfea2e Mon Sep 17 00:00:00 2001 From: Revnoplex <62947003+Revnoplex@users.noreply.github.com> Date: Sun, 17 Mar 2024 12:56:29 +1100 Subject: [PATCH] fix: Replace deprecated pkg_resources with importlib.metadata to clear DeprecationWarning (#2392) Signed-off-by: Lala Sabathil Signed-off-by: Revnoplex <62947003+Revnoplex@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> --- CHANGELOG.md | 3 +++ discord/__main__.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b74b924c..ac49862f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed the type-hinting of `Member.move_to` and `Member.edit` to reflect actual behavior. ([#2386](https://github.com/Pycord-Development/pycord/pull/2386)) +- Fixed a deprecation warning from being displayed when running `python -m discord -v` + by replacing the deprecated module. + ([#2392](https://github.com/Pycord-Development/pycord/pull/2392)) ### Changed diff --git a/discord/__main__.py b/discord/__main__.py index 12b5b5a1c3..ed34bdf42a 100644 --- a/discord/__main__.py +++ b/discord/__main__.py @@ -24,13 +24,13 @@ """ import argparse +import importlib.metadata import platform import sys from pathlib import Path from typing import Tuple import aiohttp -import pkg_resources import discord @@ -47,9 +47,9 @@ def show_version() -> None: "- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info) ) if version_info.releaselevel != "final": - pkg = pkg_resources.get_distribution("py-cord") - if pkg: - entries.append(f" - py-cord pkg_resources: v{pkg.version}") + version = importlib.metadata.version("py-cord") + if version: + entries.append(f" - py-cord importlib.metadata: v{version}") entries.append(f"- aiohttp v{aiohttp.__version__}") uname = platform.uname()