shopify_python
shopify_python copied to clipboard
Linter: function parameters and line breaks
When a function declaration uses type hints and needs to break across lines to stay within the character limit, we should have one parameter per line.
e.g.
def foo(self,
bar: int,
baz: str,
qux: typing.Dict[str, typing.List[int]]) -> bool
return True
and not:
def foo(self, bar: int, baz: str,
qux: typing.Dict[str, typing.List[int]]) -> bool
return True
As discussed https://github.com/Shopify/data_bang/pull/97#discussion_r105196063
@erikwright @honkfestival @cfournie does that about sum it up?
and needs to break across lines to stay within the character limit
I might even go so far as to say when it has more than two (2) typed parameters.
I'm ambivalent. @cfournie care to weigh in?
When using the Python 2 function type annotations, matching names to types becomes difficult after two typed parameters and one parameter and comment per line would alleviate that difficulty.
Using the Python 3 annotations I agree more with using one-param per line after 2 types parameters after reading these examples:
def foo(self,
bar: int,
baz: str,
qux: long) -> bool
return True
def foo(self, bar: int, baz: str, qux: long) -> bool
return True
Those examples are pretty compelling, @cfournie .
Then we're agreed.