A pre-commit hook to automatically remove string literals as type hints from argument, return, and class variable type annotations. Will only make the replacement if your file contains from __future__ import annotations
.
pip install dequote-annotations
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/MarcoGorelli/dequote-annotations
rev: v0.2.3
hooks:
- id: dequote-annotations
$ cat myfile.py
myvar: 'str'
$ dequote-annotations myfile.py
$ cat myfile.py
myvar: str
Check out pyupgrade, which I learned a lot from when writing this.