Skip to content

Conversation

yangdanny97
Copy link
Contributor

Summary

This codemod can help upgrade typing syntax to Python 3.10+ by converting unions to use | as specified in PEP604

Test Plan

hatch run python -m unittest libcst.codemod.commands.tests.test_convert_union_to_or

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 30, 2024
Copy link
Contributor

@zsol zsol left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment on lines 26 to 30
if QualifiedNameProvider.has_name(
self,
original_node,
QualifiedName(name="typing.Union", source=QualifiedNameSource.IMPORT),
):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I generally prefer early return in these cases

@yangdanny97 yangdanny97 merged commit d269872 into Instagram:main Jan 3, 2025
25 checks passed
@yangdanny97 yangdanny97 deleted the union branch January 3, 2025 00:49
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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants