What is the canon (based on some PEP) way to style a function definition with long type annotations?
Some alternatives I can conceive:
- Option 1:
def my_long_function_name_super_important(
first_long_argument_to_my_function: Union[int, str],
second: Dict[int, str],
third_arg: int = 0 ) -> (bool, int):
return (True, 1)
- Option 2:
def my_long_function_name_super_important(
first_long_argument_to_my_function: Union[int, str],
second: Dict[int, str],
third_arg: int = 0
) -> (bool, int):
return (True, 1)
- Option 3:
def my_long_function_name_super_important(
first_long_argument_to_my_function: Union[int, str],
second: Dict[int, str], third_arg: int = 0
) -> (bool, int):
return (True, 1)
- Option 4:
def my_long_function_name_super_important(
first_long_argument_to_my_function: Union[int, str],
second: Dict[int, str],
third_arg: int = 0,
) -> (bool, int):
return (True, 1)
Note: targeting Python 3.8+ to get an up-to-date answer.
black
formatter seems to have gained serious adoption, but it's still not official and thus "opinion". – Folkwayblack
recommends as formatting? – Varioloiddef
) till the end of the block should be indented. – Haemostaticdef
block but the head of thedef
statement itself. – Folkway