Rework typeshed-sync workflow to also add docstrings for Windows- and MacOS-specific APIs (#19360)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run

This commit is contained in:
Alex Waygood 2025-07-15 18:14:32 +01:00 committed by GitHub
parent 78dfc8af0f
commit 8d7d02193e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 160 additions and 46 deletions

27
scripts/codemod_docstrings.sh Executable file
View file

@ -0,0 +1,27 @@
#!/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.14 before running with
# any other Python version so that we get the Python 3.14 version of the
# docstring for a definition that exists on all Python versions: if we
# ran with Python 3.9 first, then the later runs with Python 3.10+ 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
docstring_adder="git+https://github.com/astral-sh/docstring-adder.git@7f350b03ee83dd44ebd8010228ad3dfca34a7887"
stdlib_path="./crates/ty_vendored/vendor/typeshed/stdlib"
for python_version in 3.14 3.13 3.12 3.11 3.10 3.9
do
uvx --python="$python_version" --force-reinstall --from="${docstring_adder}" add-docstrings --stdlib-path="${stdlib_path}"
done