Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ repos:
|/_testing/
- id: autotyping
name: autotyping
entry: python -m libcst.tool codemod autotyping.AutotypeCommand --aggressive
entry: python -m scripts.run_autotyping
types_or: [python, pyi]
files: ^pandas
exclude: ^(pandas/tests|pandas/_version.py|pandas/io/clipboard)
Expand Down
34 changes: 34 additions & 0 deletions scripts/run_autotyping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Script to run ``autotyping``, to get around the fact that
pre-commit puts ``args`` before the list of files, whereas
``autotyping`` wants the files to come after, see
https://github.com/pandas-dev/pandas/issues/48808#issuecomment-1259711679.
"""
from __future__ import annotations

import argparse
import subprocess
import sys
from typing import Sequence


def main(argv: Sequence[str] | None = None) -> None:
parser = argparse.ArgumentParser()
parser.add_argument("paths", nargs="*")
args = parser.parse_args(argv)
output = subprocess.run(
[
"python",
"-m",
"libcst.tool",
"codemod",
"autotyping.AutotypeCommand",
*args.paths,
"--aggressive",
],
)
sys.exit(output.returncode)


if __name__ == "__main__":
main()