Skip to content

Commit

Permalink
Merge pull request #200 from jorenham/codegen-docs
Browse files Browse the repository at this point in the history
add docs to the `codegen/` directory
  • Loading branch information
jorenham authored Nov 25, 2024
2 parents a81186e + 7c2c3ec commit 4277692
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
10 changes: 8 additions & 2 deletions codegen/.libcst.codemod.yaml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions codegen/README.md
Original file line number Diff line number Diff line change
@@ -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
> ```
2 changes: 1 addition & 1 deletion codegen/mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 4277692

Please sign in to comment.