Skip to content

Conversation

@zsol
Copy link

@zsol zsol commented Dec 9, 2025

Description

This PR converts all Python 2-style type annotations (in comments) into Python 3-style annotations (after : tokens, and inside the AST).

There's a large amount of changes in here, apologies for that. I generated these changes using:

  1. A LibCST codemod to do the bulk of the work: uv run --with libcst python -m libcst.tool codemod convert_type_comments.ConvertTypeComments --no-format -j1 sentry_sdk
  2. Some manual fixups here and there (see below)
  3. Run com2ann to fix the rest: uvx com2ann sentry_sdk
  4. Reformat: uvx ruff format sentry_sdk

Manual changes

  • The LibCST command made a bunch of silly mistakes like turning foo = None # type: Foo # noqa into foo: "Foo # noqa" = None, which were trivial to fix
  • When turning foo = None # type: Foo into foo: Foo = None, mypy starts raising an error on the second form - I suppressed these using type: ignore[assignment]

Test plan

mypy should continue being green, as evidenced by running uvx tox -e linters

@zsol zsol marked this pull request as ready for review December 9, 2025 17:49
@zsol zsol requested a review from a team as a code owner December 9, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant