Skip to content

Migrate Python formatter from yapf to black#182966

Open
harryterkelsen wants to merge 3 commits intoflutter:masterfrom
harryterkelsen:migrate-to-black
Open

Migrate Python formatter from yapf to black#182966
harryterkelsen wants to merge 3 commits intoflutter:masterfrom
harryterkelsen:migrate-to-black

Conversation

@harryterkelsen
Copy link
Contributor

Migrates the engine's Python formatting from yapf to black. yapf depends on lib2to3 which was removed in Python 3.13, causing failures on machines with newer Python versions.

Changes:

  • Added black CIPD package to DEPS.
  • Created black.sh/bat wrappers in tools/ to use the CIPD-managed black.
  • Updated format.dart to use black instead of yapf.
  • Added pyproject.toml for black configuration (line-length = 100).
  • Removed yapf scripts and configuration.

Fixes #158384

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Migrates the engine\'s Python formatting from yapf to black.
yapf depends on lib2to3 which was removed in Python 3.13, causing
failures on machines with Python 3.14.

Changes:
- Added black CIPD package to DEPS.
- Created black.sh/bat wrappers in tools/ to use the CIPD-managed black.
- Updated format.dart to use black instead of yapf.
- Added pyproject.toml for black configuration (line-length = 100).
- Removed yapf scripts and configuration.
- Updated documentation and code comments.
@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-fuchsia Fuchsia code specifically e: impeller Impeller rendering backend issues and features requests labels Feb 26, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the Python code formatter from yapf to black. This includes removing yapf configuration and scripts, adding black configuration in pyproject.toml and wrapper scripts, and updating the format.dart script to use black for Python formatting. A large number of Python files have been reformatted with black, and documentation has been updated to reflect this change.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

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

Labels

e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. platform-fuchsia Fuchsia code specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Python formatting to a supported formatter

1 participant