Skip to content

Conversation

@scotts
Copy link
Contributor

@scotts scotts commented Dec 4, 2025

Fixes #1033.

I did not do this manually. :) Claude did the conversions, with a few rounds of prompting. I had to do some manual un-doing of changes to our tutorials, as those are formatted for the particular rendering we get.

Note that one actual change is that I upped our Python version in pyproject.toml. Because we never bumped that up from 3.8, Claude initially put from __future__ import annotations all over the place.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 4, 2025
@scotts scotts marked this pull request as ready for review December 5, 2025 03:02
Copy link
Contributor

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks, this is much nicer!

I think we'll want a linter rule now, to enforce the new style? pyupgrade looks like what we'd want. It comes with pre-commit hooks too, so we can put it on the CI.

I ran it locally on this PR with:

find src -type f | grep ".py$" | xargs pyupgrade --py310-plus

and the good news is that your PR is spot-on, the only added changes were:

from typing import Generator  # before
from collections.abc import Generator  # now

There were a few more minor changes in the test.

@scotts
Copy link
Contributor Author

scotts commented Dec 5, 2025

@NicolasHug, yup, agreed, I created #1102 to track the CI change.

@scotts scotts merged commit a6cd9c0 into meta-pytorch:main Dec 5, 2025
82 of 90 checks passed
@scotts scotts deleted the refactor_type_annotations branch December 5, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use modern Python type annotation syntax

2 participants