Skip to content

Conversation

onerandomusername
Copy link
Member

@onerandomusername onerandomusername commented Sep 2, 2025

Summary

Support python 3.14. All of our dependencies allow it at this point in time.

depends on #1328

Reviews/contributions are useful at any point in time.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@onerandomusername onerandomusername changed the title fix: don't return within a finally block fix: support python 3.14 Sep 2, 2025
@onerandomusername onerandomusername requested review from shiftinv and Snipy7374 and removed request for shiftinv September 2, 2025 17:13
@onerandomusername onerandomusername changed the title fix: support python 3.14 feat: support python 3.14 Sep 2, 2025
@onerandomusername onerandomusername requested a review from a team as a code owner September 2, 2025 17:17
@shiftinv shiftinv added t: meta Changes to the project itself (CI, configs, etc.) t: refactor/typing/lint Refactors, typing changes and/or linting changes labels Sep 2, 2025
@onerandomusername onerandomusername force-pushed the feat/support-py314 branch 4 times, most recently from 1a0d1f6 to c538624 Compare September 2, 2025 17:30
@shiftinv shiftinv added this to the disnake v2.11 milestone Sep 7, 2025
Comment on lines -171 to 185
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
experimental: [false]
include:
- python-version: '3.14.0-alpha - 3.14'
experimental: true
os: "ubuntu-latest"
- python-version: '3.14.0-alpha - 3.14'
experimental: true
os: "windows-latest"
- python-version: '3.14.0-alpha - 3.14'
experimental: true
os: "macos-latest"
fail-fast: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also work:

    strategy:
      matrix:
        python:
          - version: "3.8"
          - version: "3.9"
          - version: "3.10"
          - version: "3.11"
          - version: "3.12"
          - version: "3.13"
          - version: "3.14"
            experimental: true
        os: ["windows-latest", "ubuntu-latest", "macos-latest"]
      fail-fast: true

(replacing .python-version with .python.version and .experimental with .python.experimental below)

try:
return asyncio.get_running_loop()
except RuntimeError:
return asyncio.new_event_loop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return asyncio.new_event_loop()
asyncio.set_event_loop(loop := asyncio.new_event_loop())
return loop

(see https://github.com/python/cpython/blob/v3.12.11/Lib/asyncio/events.py#L699)

@@ -355,7 +355,7 @@ def before_invoke(self, coro: CFT) -> CFT:
TypeError
The coroutine passed is not actually a coroutine.
"""
if not asyncio.iscoroutinefunction(coro):
if not disnake.utils.iscoroutinefunction(coro):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not disnake.utils.iscoroutinefunction(coro):
if not iscoroutinefunction(coro):

Comment on lines -510 to +511
finally:
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes this method's behavior

@@ -123,9 +123,9 @@ async def _call_external_error_handlers(
if local is not None:
stop_propagation = await local(inter, error)
# User has an option to cancel the global error handler by returning True
finally:
except Exception:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
self.loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
self.loop: asyncio.AbstractEventLoop = utils.get_event_loop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar issue here, docstring still mentions asyncio.get_event_loop.

Comment on lines 200 to -204
except Exception:
_log.exception("An error occurred while stopping the gateway. Ignoring.")
return
finally:
self.stop()
return # noqa: B012
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also changes behavior, continuing to heartbeat after closing the ws.
As noted in the PEP and B012, return in finally can swallow exceptions (in this case only BaseExceptions), which I would argue is fine here; the thread is at the end of its lifecycle anyway.

@@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines -581 to +582
else:
_log.info("Probe found codec=%s, bitrate=%s", codec, bitrate)
finally:
return codec, bitrate # noqa: B012
_log.info("Probe found codec=%s, bitrate=%s", codec, bitrate)
return codec, bitrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else part should've been fine here.

@@ -50,6 +50,22 @@

from .enums import Locale

if sys.version_info >= (3, 11):
from inspect import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iscoroutine isn't being used anywhere, as far as I can tell, and asyncio.iscoroutine isn't deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: meta Changes to the project itself (CI, configs, etc.) t: refactor/typing/lint Refactors, typing changes and/or linting changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants