一个用于自动替换类型注解中字符串字面量的工具。
项目描述
dequote-annotations
一个预提交钩子,用于自动从参数、返回和类变量类型注解中移除字符串字面量。只有当您的文件包含 from __future__ import annotations
时,才会进行替换。
安装
pip安装dequote-annotations
作为预提交钩子
有关说明,请参阅 pre-commit
示例 .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
另请参阅
检查 pyupgrade,我在编写这个工具时从中学到了很多。
项目详情
下载文件
下载适用于您的平台文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源分发
dequote_annotations-0.2.3.tar.gz (3.8 kB 查看散列)