From 6bcecb2234fbf95872d33b8097adc39ed153af62 Mon Sep 17 00:00:00 2001 From: vi <8530778+shiftinv@users.noreply.github.com> Date: Sun, 29 Dec 2024 18:11:50 +0100 Subject: [PATCH] build: support Python 3.13 (#1263) --- .github/workflows/lint-test.yml | 1 + changelog/1263.misc.rst | 1 + disnake/player.py | 16 +++++++++++++--- noxfile.py | 2 +- pyproject.toml | 3 ++- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 changelog/1263.misc.rst diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index ef519ed570..093418dbdc 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -54,6 +54,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + # FIXME: using specific patch version for 3.12 due to pdm bug python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.7"] experimental: [false] fail-fast: false diff --git a/changelog/1263.misc.rst b/changelog/1263.misc.rst new file mode 100644 index 0000000000..c12302a702 --- /dev/null +++ b/changelog/1263.misc.rst @@ -0,0 +1 @@ +Support Python 3.13. diff --git a/disnake/player.py b/disnake/player.py index 8012d640b4..1eaf0d45a7 100644 --- a/disnake/player.py +++ b/disnake/player.py @@ -25,9 +25,14 @@ from .voice_client import VoiceClient -with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - import audioop +try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + import audioop + + has_audioop = True +except ImportError: + has_audioop = False MISSING = utils.MISSING @@ -660,6 +665,11 @@ class PCMVolumeTransformer(AudioSource, Generic[AT]): """ def __init__(self, original: AT, volume: float = 1.0) -> None: + if not has_audioop: + raise RuntimeError( + f"audioop-lts library needed in Python >=3.13 in order to use {type(self).__name__}" + ) + if not isinstance(original, AudioSource): raise TypeError(f"expected AudioSource not {original.__class__.__name__}.") diff --git a/noxfile.py b/noxfile.py index 326ae81f6d..89a18ffb71 100644 --- a/noxfile.py +++ b/noxfile.py @@ -202,7 +202,7 @@ def pyright(session: nox.Session) -> None: pass -@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"]) +@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]) @nox.parametrize( "extras", [ diff --git a/pyproject.toml b/pyproject.toml index 777507fb7c..d3c3267537 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", @@ -51,6 +52,7 @@ speed = [ ] voice = [ "PyNaCl>=1.5.0,<1.6", + 'audioop-lts==0.2.1; python_version >= "3.13"' ] docs = [ "sphinx==7.0.1", @@ -125,7 +127,6 @@ runner = "pdm run" [tool.black] line-length = 100 -target-version = ["py38", "py39", "py310", "py311", "py312"] [tool.ruff] line-length = 100