PyCQA/pycodestyle

E126: asks for less indent on one-line protocol functions

開放

#956 建立於 2020年8月5日

 (1 則留言) (1 個反應) (0 位負責人)Python (809 個分叉)batch import
help wantedneeds patchneeds test

倉庫指標

星標
 (4,941 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

from typing import Protocol


class _LongPollProtocol(Protocol):
    def __call__(
            self,
            foo: str,
            bar: int,
    ) -> int: ...

running pycodestyle on this yields:

$ ~/opt/venv/bin/pycodestyle --version
2.6.0
$ ~/opt/venv/bin/pycodestyle t.py --ignore=E704
t.py:6:13: E126 continuation line over-indented for hanging indent

but interestingly, this indentation is ok if I move the Ellipsis to the next line

from typing import Protocol


class _LongPollProtocol(Protocol):
    def __call__(
            self,
            foo: str,
            bar: int,
    ) -> int:
        ...

I intentionally want to indent the arguments two indents to differentiate between the body of code

貢獻者指南