Closed JelleZijlstra closed 8 months ago
Adding this to a pre-commit config would be fantastic. When adding types, it often helps to only auto-add types to affected files, and pre-commit makes it easy to choose those files only. Adding the .libcst.codemod.yaml
file is the most painful part of using this tool.
Definitely agree that would be useful. I don't think I'll have time to work on this soon but I'd accept a PR.
Integration with precommit does work, although a seemingly unnecessary .libcst.codemod.yaml
is required:
generated_code_marker: '@generated'
modules:
- 'libcst.codemod.commands'
- 'autotyping'
repo_root: '.'
The following precommit hook does work for me:
repos:
- repo: local
hooks:
- id: autotype_init
name: autotype_init
entry: python
language: system
types: [python]
args: ["-m", "libcst.tool", "codemod", "--hide-progress",
"autotyping.AutotypeCommand", "--annotate-magics"]
require_serial: true
Current setup is not bad except my autotyping parameters are inside precommit yaml instead in the config file of newly added LibCST.
@hauntsaninja fixed this in #65, thanks!
I would like users to be able to run just
python -m autotyping --safe path/to/dir/
without having to go through setting up a LibCST config. Unfortunatelylibcst.tool
is fairly rigid and I don't see a good way to do this while preserving the ability to pass other kinds of arguments that LibCST accepts directly. Perhaps there can be a simple mode that is justpython -m autotyping
and an advanced mode that allows more flexibility.I'd be interested in user feedback about what kind of interface would be helpful.