| #!/usr/bin/env bash | |
| # This script uses the https://github.com/astral-sh/docstring-adder tool to codemod docstrings into our vendored typeshed stubs. | |
| # | |
| # We run the tool with the full matrix of Python versions supported by typeshed, | |
| # so that we codemod in docstrings that only exist on certain versions. | |
| # | |
| # The codemod will only add docstrings to functions/classes that do not | |
| # already have docstrings. We run with Python 3.15 before running with | |
| # any other Python version so that we get the Python 3.15 version of the | |
| # docstring for a definition that exists on all Python versions: if we | |
| # ran with Python 3.10 first, then the later runs with Python 3.11+ would | |
| # not modify the docstring that had already been added using the old version of Python. | |
| # | |
| # Note that the codemod can only add docstrings if they exist on the Python platform | |
| # the codemod is run with. If you need to add docstrings for a Windows-specific API, | |
| # you'll need to run the codemod on a Windows machine. | |
| set -eu | |
| stdlib_path="./crates/ty_vendored/vendor/typeshed/stdlib" | |
| for python_version in 3.15 3.14 3.13 3.12 3.11 3.10 | |
| do | |
| PYTHONUTF8=1 uv run \ | |
| --locked \ | |
| --only-group=typeshed-docstrings \ | |
| --python="$python_version" \ | |
| add-docstrings \ | |
| --stdlib-path="${stdlib_path}" | |
| done |