Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
min_python_version = 3.10
min_python_version = 3.11

# Incompatible with black see https://github.com/ambv/black/issues/315
ignore =
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lib-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.10", "3.14" ]
python-version: [ "3.11", "3.15" ]
steps:
- name: "Checkout Repository"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -191,7 +191,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
python-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ]
steps:
- name: "Checkout Repository"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
hooks:
- id: pyupgrade
exclude: \.(po|pot|yml|yaml)$
args: [--py310-plus]
args: [--py311-plus]
- repo: https://github.com/PyCQA/isort
rev: 9.0.1
hooks:
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for D
Note
----

Pycord supports Python ``3.10`` - ``3.14``
Pycord supports Python ``3.11`` - ``3.15``

Key Features
------------
Expand All @@ -45,7 +45,7 @@ Key Features
Installing
----------

**Python 3.10 or higher is required**
**Python 3.11 or higher is required**

To install the library without full voice support, run the following command:

Expand Down Expand Up @@ -105,7 +105,7 @@ Optional Packages
Please note that while installing voice support on Linux, you must install the following packages via your preferred package manager (e.g. ``apt``, ``dnf``, etc) BEFORE running the above commands:

* libffi-dev (or ``libffi-devel`` on some systems)
* python-dev (e.g. ``python3.10-dev`` for Python 3.10)
* python-dev (e.g. ``python3.11-dev`` for Python 3.11)

Quick Example
-------------
Expand Down
4 changes: 2 additions & 2 deletions discord/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import warnings
from importlib.metadata import PackageNotFoundError, version

from typing_extensions import TypedDict, deprecated
from typing_extensions import deprecated

__all__ = ("__version__", "VersionInfo", "version_info")

from typing import Literal, NamedTuple
from typing import Literal, NamedTuple, TypedDict

try:
__version__ = version("py-cord")
Expand Down
4 changes: 2 additions & 2 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ async def connect(

Raises
------
asyncio.TimeoutError
TimeoutError
Could not connect to the voice channel in time.
~discord.ClientException
You are already connected to a voice channel.
Expand Down Expand Up @@ -2087,7 +2087,7 @@ async def connect(

try:
await voice.connect(timeout=timeout, reconnect=reconnect)
except asyncio.TimeoutError:
except TimeoutError:
try:
await voice.disconnect(force=True)
except Exception:
Expand Down
20 changes: 8 additions & 12 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def created_at(self) -> datetime.datetime | None:
"""
if self._created_at is not None:
return datetime.datetime.fromtimestamp(
self._created_at / 1000, tz=datetime.timezone.utc
self._created_at / 1000, tz=datetime.UTC
)

def to_dict(self) -> ActivityPayload:
Expand Down Expand Up @@ -288,7 +288,7 @@ def start(self) -> datetime.datetime | None:
except KeyError:
return None
else:
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)

@property
def end(self) -> datetime.datetime | None:
Expand All @@ -298,7 +298,7 @@ def end(self) -> datetime.datetime | None:
except KeyError:
return None
else:
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)

@property
def large_image_url(self) -> str | None:
Expand Down Expand Up @@ -398,18 +398,14 @@ def type(self) -> ActivityType:
def start(self) -> datetime.datetime | None:
"""When the user started playing this game in UTC, if applicable."""
if self._start:
return datetime.datetime.fromtimestamp(
self._start / 1000, tz=datetime.timezone.utc
)
return datetime.datetime.fromtimestamp(self._start / 1000, tz=datetime.UTC)
return None

@property
def end(self) -> datetime.datetime | None:
"""When the user will stop playing this game in UTC, if applicable."""
if self._end:
return datetime.datetime.fromtimestamp(
self._end / 1000, tz=datetime.timezone.utc
)
return datetime.datetime.fromtimestamp(self._end / 1000, tz=datetime.UTC)
return None

def __str__(self) -> str:
Expand Down Expand Up @@ -606,7 +602,7 @@ def created_at(self) -> datetime.datetime | None:
"""
if self._created_at is not None:
return datetime.datetime.fromtimestamp(
self._created_at / 1000, tz=datetime.timezone.utc
self._created_at / 1000, tz=datetime.UTC
)

@property
Expand Down Expand Up @@ -713,14 +709,14 @@ def track_url(self) -> str:
def start(self) -> datetime.datetime:
"""When the user started playing this song in UTC."""
return datetime.datetime.fromtimestamp(
self._timestamps["start"] / 1000, tz=datetime.timezone.utc
self._timestamps["start"] / 1000, tz=datetime.UTC
)

@property
def end(self) -> datetime.datetime:
"""When the user will stop playing this song in UTC."""
return datetime.datetime.fromtimestamp(
self._timestamps["end"] / 1000, tz=datetime.timezone.utc
self._timestamps["end"] / 1000, tz=datetime.UTC
)

@property
Expand Down
9 changes: 4 additions & 5 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from __future__ import annotations

import asyncio
import collections
import collections.abc
import copy
Expand Down Expand Up @@ -63,7 +62,7 @@
from .utils import MISSING, async_all, find, get

if TYPE_CHECKING:
from typing_extensions import Never
from typing import Never

from .cog import Cog
from .commands import Option
Expand Down Expand Up @@ -907,7 +906,7 @@ async def callback() -> None:
check=lambda i, c: c == command,
timeout=3,
)
except asyncio.TimeoutError:
except TimeoutError:
return
else:
if not autocomplete_task.done():
Expand Down Expand Up @@ -1535,7 +1534,7 @@ def before_invoke(self, coro):
TypeError
The coroutine passed is not actually a coroutine.
"""
if not asyncio.iscoroutinefunction(coro):
if not inspect.iscoroutinefunction(coro):
raise TypeError("The pre-invoke hook must be a coroutine.")

self._before_invoke = coro
Expand Down Expand Up @@ -1567,7 +1566,7 @@ def after_invoke(self, coro):
The coroutine passed is not actually a coroutine.

"""
if not asyncio.iscoroutinefunction(coro):
if not inspect.iscoroutinefunction(coro):
raise TypeError("The post-invoke hook must be a coroutine.")

self._after_invoke = coro
Expand Down
31 changes: 21 additions & 10 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from __future__ import annotations

import asyncio
import inspect
import logging
import signal
import sys
Expand All @@ -35,11 +36,13 @@
from typing import (
TYPE_CHECKING,
Any,
Self,
TypeVar,
overload,
)

import aiohttp
from typing_extensions import Self, deprecated
from typing_extensions import deprecated

from . import utils
from .activity import ActivityTypes, BaseActivity, create_activity
Expand Down Expand Up @@ -732,7 +735,7 @@ async def connect(self, *, reconnect: bool = True) -> None:
GatewayNotFound,
ConnectionClosed,
aiohttp.ClientError,
asyncio.TimeoutError,
TimeoutError,
) as exc:
self.dispatch("disconnect")
if not reconnect:
Expand Down Expand Up @@ -1273,7 +1276,7 @@ def wait_for(

The ``timeout`` parameter is passed onto :func:`asyncio.wait_for`. By default,
it does not timeout. Note that this does propagate the
:exc:`asyncio.TimeoutError` for you in case of timeout and is provided for
:exc:`TimeoutError` for you in case of timeout and is provided for
ease of use.

In case the event returns multiple arguments, a :class:`tuple` containing those
Expand All @@ -1293,7 +1296,7 @@ def wait_for(
parameters of the event being waited for.
timeout: Optional[:class:`float`]
The number of seconds to wait before timing out and raising
:exc:`asyncio.TimeoutError`.
:exc:`TimeoutError`.

Returns
-------
Expand All @@ -1304,7 +1307,7 @@ def wait_for(

Raises
------
asyncio.TimeoutError
TimeoutError
Raised if a timeout is provided and reached.

Examples
Expand Down Expand Up @@ -1337,7 +1340,7 @@ def check(reaction, user):

try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
except TimeoutError:
await channel.send('\N{THUMBS DOWN SIGN}')
else:
await channel.send('\N{THUMBS UP SIGN}')
Expand Down Expand Up @@ -1395,7 +1398,7 @@ async def my_message(message): pass
if not name.startswith("on_"):
raise ValueError("The 'name' parameter must start with 'on_'")

if not asyncio.iscoroutinefunction(func):
if not inspect.iscoroutinefunction(func):
raise TypeError("Listeners must be coroutines")

if name in self._event_handlers:
Expand Down Expand Up @@ -1429,7 +1432,15 @@ def remove_listener(self, func: Coro, name: str = MISSING) -> None:
except ValueError:
pass

def listen(self, name: str = MISSING, once: bool = False) -> Callable[[Coro], Coro]:
@overload
def listen(self, name: Coro, once: bool = False) -> Coro: ...

@overload
def listen(
self, name: str = MISSING, once: bool = False
) -> Callable[[Coro], Coro]: ...

def listen(self, name=MISSING, once=False):
"""A decorator that registers another function as an external
event listener. Basically this allows you to listen to multiple
events from different places e.g. such as :func:`.on_ready`
Expand Down Expand Up @@ -1475,7 +1486,7 @@ def decorator(func: Coro) -> Coro:
self.add_listener(func, name)
return func

if asyncio.iscoroutinefunction(name):
if inspect.iscoroutinefunction(name):
coro = name
name = coro.__name__
return decorator(coro)
Expand Down Expand Up @@ -1510,7 +1521,7 @@ async def on_ready():
print('Ready!')
"""

if not asyncio.iscoroutinefunction(coro):
if not inspect.iscoroutinefunction(coro):
raise TypeError("event registered must be a coroutine function")

setattr(self, coro.__name__, coro)
Expand Down
4 changes: 2 additions & 2 deletions discord/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

import colorsys
import random
from typing import Any
from typing import Any, Self

from typing_extensions import Self, deprecated, override
from typing_extensions import deprecated, override

__all__ = (
"Colour",
Expand Down
Loading
Loading