Skip to content

yapf will fail on Python >= 3.13 because lib2to3 was removed #1265

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Feb 7, 2025

lib2to3 has been removed from the standard library in Python 3.13.

Document the incompatibility and the need for:

`lib2to3` has been removed from the standard library in Python 3.13.

Document the incompatibility and the need for:
* google#1258
@Spitfire1900
Copy link
Contributor

Spitfire1900 commented Feb 8, 2025

This isn't true, lib2to3 is no longer used by YAPF since #1067 .

The project does still need to move off even the forked version though because it's not feasible to patch _ylib2to3 with new Python language features.

@ python --version; python -m yapf --diff get-pip.py
Python 3.14.0a1
--- get-pip.py  (original)
+++ get-pip.py  (reformatted)
@@ -28,11 +28,11 @@
     message_parts = [
         "This script does not work on Python {}.{}.".format(*this_python),
         "The minimum supported Python version is {}.{}.".format(*min_version),
-        "Please use https://bootstrap.pypa.io/pip/{}.{}/get-pip.py instead.".format(*this_python),
+        "Please use https://bootstrap.pypa.io/pip/{}.{}/get-pip.py instead.".
+        format(*this_python),
     ]
     print("ERROR: " + " ".join(message_parts))
     sys.exit(1)
-

 import os.path
 import pkgutil
@@ -28835,6 +28835,5 @@
 a4%nWWo~3|axZmqY;0*_GcR>?X>2cdVQF+OaCuNm1qJ{B006H6uL0$R000pt8vp<R
 """

-
 if __name__ == "__main__":
     main()

@cclauss
Copy link
Contributor Author

cclauss commented Feb 8, 2025

Awesome. Thanks much for your work on this.

@cclauss cclauss closed this Feb 8, 2025
@cclauss cclauss deleted the patch-1 branch February 8, 2025 14:56
python-version: ["3.8", "3.11", "3.12"] # no particular need for 3.9 or 3.10
# Python >= 3.13 will fail with `ModuleNotFoundError: No module named 'lib2to3'`
# See: google/yapf#1258
python-version: ["3.8", "3.11", "3.12", "3.13"] # no particular need for 3.9 or 3.10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still might be useful to add Py313 to the testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably drop 3.11 and 3.12 from the list. There's some special cases with 3.8 left in implementation code but 3.13 functionally tests everything >3.10 or greater.

There's also no special 3.9 code.

cclauss added a commit to cclauss/yapf that referenced this pull request Feb 9, 2025
```
      matrix:
        # There is version-specific code for Python 3.8 but none for 3.9.
        # Python 3.13 functionally tests everything for Python >= v3.10.
        python-version: ["3.8", "3.13"]
```
Python 3.8 is now [end-of-life](https://devguide.python.org/versions) but still worth testing.

As discussed at google#1265 (comment)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants