Skip to content

chore: Codebase cleanup after going python 3.10+#2988

Open
Lulalaby wants to merge 22 commits into
masterfrom
cleanup/39-removal-314-prepare
Open

chore: Codebase cleanup after going python 3.10+#2988
Lulalaby wants to merge 22 commits into
masterfrom
cleanup/39-removal-314-prepare

Conversation

@Lulalaby
Copy link
Copy Markdown
Member

@Lulalaby Lulalaby commented Nov 1, 2025

Depends on #2948

This basically just runs pyupgrade --py310-plus on the codebase.

@Lulalaby Lulalaby added this to the v2.7 milestone Nov 1, 2025
@Lulalaby Lulalaby added the dependencies Pull requests that update a dependency file label Nov 1, 2025
@github-project-automation github-project-automation Bot moved this to In Progress in Pycord Releases Nov 1, 2025
@pycord-app
Copy link
Copy Markdown

pycord-app Bot commented Nov 1, 2025

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/2988/head:pr-2988
git checkout pr-2988

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2988/head

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the codebase by migrating from typing_extensions to the standard typing module for features that are now available in Python 3.10+. Since the project requires Python >= 3.10, these imports can be safely moved to the standard library. Additionally, the PR updates the event loop initialization in the Client class to avoid deprecation warnings in Python 3.11+.

Key changes:

  • Migrated TypedDict, ParamSpec, Concatenate, TypeGuard, Literal, Annotated, get_args, and get_origin from typing_extensions to typing
  • Removed Python 3.10 version checks and related code paths that are no longer needed
  • Updated event loop initialization to use asyncio.get_running_loop() with fallback to asyncio.new_event_loop() to avoid deprecation warnings

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
discord/utils.py Migrated ParamSpec import; removed sys import, PY_310 version check, and Python < 3.10 code path for literal flattening
discord/types/*.py Migrated TypedDict from typing_extensions to typing across multiple type definition files
discord/ext/commands/core.py Migrated Concatenate, ParamSpec, and TypeGuard imports
discord/ext/commands/context.py Migrated ParamSpec import
discord/commands/core.py Removed sys import and Python 3.11 version check; migrated Annotated, Literal, get_args, get_origin, Concatenate, and ParamSpec imports
discord/commands/context.py Migrated ParamSpec import and consolidated imports on single line
discord/client.py Updated event loop initialization to avoid asyncio.get_event_loop() deprecation warning
discord/_version.py Migrated TypedDict import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread discord/client.py Outdated
Comment thread discord/utils.py
Copy link
Copy Markdown

Copilot AI commented Nov 2, 2025

@Lulalaby I've opened a new pull request, #2989, to work on those changes. Once the pull request is ready, I'll request review from you.

@Lulalaby Lulalaby marked this pull request as ready for review November 2, 2025 03:27
@Lulalaby Lulalaby requested a review from a team as a code owner November 2, 2025 03:27
@Paillat-dev Paillat-dev force-pushed the master branch 2 times, most recently from 45025bd to 01e9fa8 Compare April 14, 2026 10:21
@Paillat-dev Paillat-dev modified the milestones: 2.9.0, 2.8.1 May 22, 2026
@Paillat-dev Paillat-dev changed the title fix: cleanup of 3.9 removal and preparation for 3.14 chore: Codebase cleanup after 3.14 May 22, 2026
@Paillat-dev Paillat-dev changed the title chore: Codebase cleanup after 3.14 chore: Codebase cleanup after py3.14 May 22, 2026
@Paillat-dev Paillat-dev marked this pull request as ready for review May 22, 2026 10:18
@Paillat-dev Paillat-dev requested review from a team May 22, 2026 10:18
@Paillat-dev Paillat-dev requested a review from a team as a code owner May 22, 2026 10:18
@Paillat-dev Paillat-dev requested a review from ToothyDev May 22, 2026 10:18
@Paillat-dev Paillat-dev changed the title chore: Codebase cleanup after py3.14 chore: Codebase cleanup after going python 3.10+ May 22, 2026
Comment thread discord/commands/core.py
Comment on lines 70 to +73
if sys.version_info >= (3, 11):
from typing import Annotated, Literal, get_args, get_origin
else:
from typing_extensions import Annotated, Literal, get_args, get_origin
from typing import Annotated, Literal, get_args, get_origin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These are the same imports

@ToothyDev
Copy link
Copy Markdown
Contributor

ToothyDev commented May 22, 2026

Otherwise looks good to me, tested on both 3.10 and 3.14 on my own bot and seems to work fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

Status: Todo
Status: In Progress

Development

Successfully merging this pull request may close these issues.

7 participants