'Long return type hint and pep8

I have a function that raises an E501 line too long (86 > 79 characters) warning when running pycodestyle.

def my_function(arg1: list = None) -> Tuple[pd.DataFrame, pd.DataFrame, pd.Dataframe]:
    # do stuff
    return df1, df2, df3

What is the best solution for formatting long return type hints (preferably without changing the format of the arguments? e.g.

def my_function(arg1: list = None) -> Tuple[pd.DataFrame,
                                            pd.DataFrame,
                                            pd.Dataframe]:


Solution 1:[1]

How about you use black. This will automatically format the code for you. Keep it mind to have same line lengths for both black and pycodestyle

Solution 2:[2]

You could try \:

def my_function(arg1: list = None)\
        -> Tuple[pd.DataFrame, pd.DataFrame, pd.Dataframe]:

Solution 3:[3]

Put the closing parenthesis and the return type hint on the next line:

def my_function(arg1: list = None
    ) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
    # do stuff
    return df1, df2, df3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shahidammer
Solution 2 Kevin Mayo
Solution 3 audiomason