自动应用强大的walrus运算符
项目描述
auto-walrus
auto-walrus
自动应用强大的walrus运算符的工具和pre-commit钩子。
安装
pip install auto-walrus
作为pre-commit钩子的使用
有关说明,请参阅pre-commit
示例 .pre-commit-config.yaml
- repo: https://github.com/MarcoGorelli/auto-walrus
rev: 0.3.4
hooks:
- id: auto-walrus
命令行示例
auto-walrus myfile.py
- n = 10
- if n > 3:
+ if (n := 10) > 3:
print(n)
配置
使用walrus运算符可能会导致行变长。超过您传递给--line-length
的行不会重写以使用walrus运算符。
例如。
auto-walrus myfile_1.py myfile_2.py --line-length 89
带有注释的行不会被重写。
使用情况
令我惊讶的是,它正在被以下项目使用
- https://github.com/python-graphblas/python-graphblas
- https://github.com/Remi-Gau/bids2cite
- https://github.com/TheAlgorithms/Python
- https://github.com/apache/superset
其他人吗?请让我知道,或者您可以打开一个pull请求来添加自己。
推荐信
Christopher Redwine,TechnologyAdvice的高级软件工程师
嗯,我不知道这个怎么样,老大
Michael Kennedy & Brian Okken,Python Bytes播客的主播
我喜欢这个和其他工具分开
Discord上的人
你是个怪物
Will McGugan,Textualize.io的CEO / 创始人
拥抱walrus!
致谢
标志由lion_space设计
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
auto_walrus-0.3.4.tar.gz (9.8 kB 查看散列值)
构建分发
auto_walrus-0.3.4-py3-none-any.whl (6.7 kB 查看散列值)