Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docs to the codegen/ directory #200

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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