hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.56k stars 288 forks source link

Long line containing the await keyword is not being formatted while similar line without await does get proper formatting #771

Open ilanKeshet opened 2 weeks ago

ilanKeshet commented 2 weeks ago

Python Code

SOME_CONST_IT_DOESNT_REALLY_MATTER = "some_const"

async def some_async_function():
    some_function_which_takes_some_parameters(await some_other_async_function_returning_a_string(), SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_function_which_takes_some_parameters(*args, **kwargs):
    return args

async def some_other_async_function_returning_a_string() -> str:
    return "some string"

async def some_none_async_function():
    some_function_which_takes_some_parameters(some_other_non_async_function_returning_a_string(), SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_other_non_async_function_returning_a_string() -> str:
    return "some string"

Command Line and Configuration

-   repo: https://github.com/hhatto/autopep8
    rev: 'v2.3.1'
    hooks:
    -   id: autopep8
        args: ["--in-place", "--max-line-length", "120", "--experimental", "--ignore" , "E301"]

Command Line

$ autopep8 --in-place --max-line-length 120 --experimental --ignore E301

Your Environment

Expected result

SOME_CONST_IT_DOESNT_REALLY_MATTER = "some_const"

async def some_async_function():
    some_function_which_takes_some_parameters(
        await some_other_async_function_returning_a_string(),
        SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_function_which_takes_some_parameters(*args, **kwargs):
    return args

async def some_other_async_function_returning_a_string() -> str:
    return "some string"

async def some_none_async_function():
    some_function_which_takes_some_parameters(
        some_other_non_async_function_returning_a_string(),
        SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_other_non_async_function_returning_a_string() -> str:
    return "some string"

Actual result

SOME_CONST_IT_DOESNT_REALLY_MATTER = "some_const"

async def some_async_function():
    some_function_which_takes_some_parameters(await some_other_async_function_returning_a_string(), SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_function_which_takes_some_parameters(*args, **kwargs):
    return args

async def some_other_async_function_returning_a_string() -> str:
    return "some string"

async def some_none_async_function():
    some_function_which_takes_some_parameters(
        some_other_non_async_function_returning_a_string(),
        SOME_CONST_IT_DOESNT_REALLY_MATTER, a_kw_arg_value=True)

def some_other_non_async_function_returning_a_string() -> str:
    return "some string"
andrewpeck commented 2 weeks ago

I am seeing this same issue.