E302 with @overload: Should the `def`s be grouped together?
stdedos opened this issue · comments
Stavros Ntentos commented
Currently, pycodestyle suggests
@overload
def process(response: None) -> None: ...
@overload
def process(response: int) -> tuple[int, str]: ...
@overload
def process(response: bytes) -> str: ...
def process(response):
... # actual implementation goes here
Should it suggest
@overload
def process(response: None) -> None: ...
@overload
def process(response: int) -> tuple[int, str]: ...
@overload
def process(response: bytes) -> str: ...
def process(response):
... # actual implementation goes here
instead?
From https://peps.python.org/pep-0008/#blank-lines
Extra blank lines may be used (sparingly) to separate groups of related functions. Blank lines may be omitted between a bunch of related one-liners (e.g. a set of dummy implementations).
Since the one-liner @overload
s are only there for the types, maybe it doesn't make sense separating them into a new section.
black --preview
accepts both styles (but fixes deviations with 2 lines)
black, 22.6.0 (compiled: yes)
Python (CPython) 3.9.18
Anthony Sottile commented
I don't think it should