【发布时间】:2021-10-27 17:28:15
【问题描述】:
我正在将 autopep8 实施到现有项目中,有时会奇怪地格式化较长的行。比如有这个代码sn -p:
client_data={'id': str(self.user.client.client_id), 'type': self.user.client.client_type},
其格式如下:
self.setup_auth(UserProxy(self.user.sub, [],
client_data={
'id': str(
self.user.client.client_id),
'type': self.user.client.client_type},
roles=[]))
所以传递给UserProxy 的参数在第一行有两个元素,然后第三个元素在新行上正确缩进,但字典的元素只缩进一次,而不是从它来的行缩进一次关闭。
如果我尝试手动修复它,它只会恢复。
有人知道我可以如何改进这种情况下的缩进吗?
编辑:
我在 pyproject.toml 中运行 autopep8
[tool.autopep8]
max_line_length = 88
in-place = true
recursive = true
aggressive = 3
【问题讨论】:
标签: python indentation pep8 autopep8