Skip to content

Update code to Python 3.11 #29840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Update code to Python 3.11 #29840

wants to merge 1 commit into from

Conversation

oscargus
Copy link
Member

PR summary

Depends on #29796

I just went the pyupgrade-route so not really sure which are actually related to dropping 3.10 and what is just old code that hangs around (like the %-formatting), but maybe just as good to get those things in as well?

PR checklist

@anntzer
Copy link
Contributor

anntzer commented Mar 31, 2025

tex strings formatting avoid using {} on purpose -- you just end up with way too many nested braces...

@oscargus
Copy link
Member Author

oscargus commented Apr 1, 2025

Yeah, they looked quite bad. Will selectively revert those and fix some other things that "looked bad".

@timhoffm
Copy link
Member

timhoffm commented Apr 1, 2025

I'd wait a bit with this until we're pretty sure there's no need for 3.10 support anymore. Not formally supporting it and actively breaking support are two pairs of shoes. Since the changes here have marginal benefits, I'd wait with them to close before/after the 3.11 release.

@timhoffm
Copy link
Member

timhoffm commented Apr 1, 2025

I'd wait a bit with this until we're pretty sure there's no need for 3.10 support anymore. Not formally supporting it and actively breaking support are two pairs of shoes. Since the changes here have marginal benefits, I'd wait with them to close before/after the 3.11 release.

Some of the changes here are not related to dropping 3.11 so could be pulled in right now (maybe run pyupgrade --py310-plus if you care to clean up older stuff now).

@oscargus oscargus marked this pull request as draft April 3, 2025 07:55
@oscargus
Copy link
Member Author

oscargus commented Apr 3, 2025

I've identified like four things here:

  • Getting rid of %-formatting: not good as it becomes lots of curly braces when used for LaTeX-like strings (almost all of the changes)
  • Location of typing imports: seems to be introduced in Python 3.11, but this is one that sort of makes sene
  • Location of UTC: datetime.UTC introduced in Python 3.11, also makes sense since it is slightly shorter
  • yield from instead of for-loop: cannot figure out version, but seems to maybe has been around for a bit, more pythonic

Hence, it is only the last one that actually can go in (and maybe a few well selected formats). Closing this for now and may reopen another one.

@oscargus oscargus closed this Apr 3, 2025
@timhoffm
Copy link
Member

timhoffm commented Apr 3, 2025

yield from was introduced in Python 3.3: https://docs.python.org/3.3/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator

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

Successfully merging this pull request may close these issues.

3 participants