diff --git a/codegen/.libcst.codemod.yaml b/codegen/.libcst.codemod.yaml index 4096f85f..faf393f2 100644 --- a/codegen/.libcst.codemod.yaml +++ b/codegen/.libcst.codemod.yaml @@ -1,5 +1,11 @@ generated_code_marker: "@generated" -formatter: ["./.venv/bin/ruff", "format", "--stdin-filename=__generated__.pyi", "-"] blacklist_patterns: [] -modules: ["libcst.codemod.commands", "codegen.mods"] repo_root: "." +formatter: + - "./.venv/bin/ruff" + - "format" + - "--stdin-filename=__generated__.pyi" + - "-" +modules: + - "libcst.codemod.commands" + - "codegen.mods" diff --git a/codegen/README.md b/codegen/README.md new file mode 100644 index 00000000..51fdb436 --- /dev/null +++ b/codegen/README.md @@ -0,0 +1,19 @@ +# `scipy-stubs/codegen` + +To run a codemod, ensure that you are in the root directory of the `scipy-stubs` repository and run: + +```bash +poe codemod $NAME +``` + +where `$NAME` is the name is the name of the codemod, which can be one of: + +- `AnnotateMissing` - Sets the default return type to `None`, and sets the other missing annotations to `scipy._typing.Untyped`. +- `FixTrailingComma` - Adds a trailing comma to parameters that don't fit on one line, so that ruff formats them correctly. + +> [!NOTE] +> The codemods require `libcst`, which is installable through the **optional** `codegen` dependency group: +> +> ```bash +> poetry install --with=codegen +> ``` diff --git a/codegen/mods.py b/codegen/mods.py index 27b58540..5eb991f7 100644 --- a/codegen/mods.py +++ b/codegen/mods.py @@ -55,7 +55,7 @@ def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> c @final class AnnotateMissing(_BaseMod): - DESCRIPTION = "Sets the default return type to `None`, and other missing annotations to `scipy._typing.Untyped`" + DESCRIPTION = "Sets the default return type to `None`, and sets the other missing annotations to `scipy._typing.Untyped`." untyped: Final[str]