Skip to content

refactor: remaining 3.10+ cleanup - #3323

Open
vmphase wants to merge 11 commits into
masterfrom
refactor/py3.10-cleanup
Open

refactor: remaining 3.10+ cleanup#3323
vmphase wants to merge 11 commits into
masterfrom
refactor/py3.10-cleanup

Conversation

@vmphase

@vmphase vmphase commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up cleanup to the automated pyupgrade --py310-plus pass in #2988, covering things that tool didn't handle:

  • Replace typing_extensions.ParamSpec with typing.ParamSpec
  • Replace deprecated typing.Deque/Deque[...] with collections.deque/deque[...]
  • Replace collections.OrderedDict with plain dict (insertion-orderguaranteed since 3.7)
  • Drop the hasattr(types, "UnionType") guard
  • Convert big if/elif chain to match/case
  • Remove PY_310 version check, pre-3.10 branch, utils.flatten_literal_params and utils.classproperty

Information

  • 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, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • I have read the Contributing Guidelines.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

@vmphase
vmphase requested review from a team July 30, 2026 09:18
@vmphase
vmphase requested review from Lulalaby and plun1331 July 30, 2026 09:18
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Jul 30, 2026
@pycord-app

pycord-app Bot commented Jul 30, 2026

Copy link
Copy Markdown

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/3323/head:pr-3323
git checkout pr-3323

This pull request can be installed with:

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

@vmphase

vmphase commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

I didn't update the changelog because all the changes are internal.
Furthermore, the #2988's changelog was not updated as well.

@Paillat-dev Paillat-dev added this to the 2.9.0rc1 milestone Jul 30, 2026
Comment thread discord/enums.py
Comment thread discord/enums.py
match self.value:
case -1:
return "all"
case v if v < 10:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also imo this hurts readability since it's not proper equivalence.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mostly went for it since it removes the repeated elif v < boilerplate. Under the hood this compiles to the same sequential guard evaluation as the if-elif chain, so there's no difference. I think the reduced repetition is worth it here, and PEP 634 explicitly documents guard clauses (case x if ...) as valid usage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Valid sure but this is more confusing in this case. In my mind case x if is for specific edge cases, not 99% of the conditions. In this case it is just more messy.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's not an actual convention and I think this comes down to preference rather than a correctness. Nothing in PEP63* suggests guards should stay rare relative to structural cases, and for a scalar subject like this there's no structural pattern to lean on in the first place, so guard-per-case is just what matching an int naturally looks like.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Of course it's preference.

Comment thread discord/utils.py Outdated
@Lulalaby
Lulalaby force-pushed the refactor/py3.10-cleanup branch from 8586889 to fea27ed Compare July 30, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants