<#23084 Pants fix fails with docformatter lib2to3 ...
# github-notifications
q
#23084 Pants fix fails with docformatter lib2to3 ModuleNotFoundError on Python 3.12 Issue created by leozc Describe the bug A clear and concise description of the bug. Pants version Which version of Pants are you using? Pants: 2.29.0 OS Are you encountering the bug on MacOS, Linux, or both? OS: Ubuntu 24.04.3 LTS (Noble Numbat) Python: 3.12.3 Additional info rror: ModuleNotFoundError: No module named 'lib2to3' The error occurs in docformatter.py when it tries to import from lib2to3.pgen2 import tokenize. Solution Pants 2.29 ships with docformatter 1.4 which doesn't support Python 3.12. Upgrade to docformatter 1.7.5+ using a custom resolve: Create 3rdparty/python/docformatter-requirements.txt: docformatter>=1.7.5 Create 3rdparty/python/BUILD: python_requirements( name="docformatter", source="docformatter-requirements.txt", resolve="docformatter", ) Update pants.toml: [python.resolves] python-default = "3rdparty/python/default.lock" docformatter = "3rdparty/python/docformatter.lock" [docformatter] install_from_resolve = "docformatter" Generate lockfile: pants generate-lockfiles --resolve=docformatter pantsbuild/pants