Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W504: positional only / keyword only argument marker at end of long line #951

Open
rharish101 opened this issue Jul 14, 2020 · 3 comments · May be fixed by #1098
Open

W504: positional only / keyword only argument marker at end of long line #951

rharish101 opened this issue Jul 14, 2020 · 3 comments · May be fixed by #1098

Comments

@rharish101
Copy link

Configuraton:

  • OS: Arch Linux
  • pycodestyle version: 2.6.0
  • Python version: 3.8.3
  • Installation source: Arch Linux packages

W504 (line break after binary operator) shows up when the slash that indicates positional-only arguments (PEP 570) is followed by a newline. For example:

def really_long_name_for_a_function(
    very_long_argument_1, very_long_argument_2, /
):
    pass

pycodestyle thinks that the slash is a binary operator. I can, however, silence it using a comma after the slash, as follows:

def really_long_name_for_a_function(
    very_long_argument_1, very_long_argument_2, /,
):
    pass

I think this is an issue, as the slash isn't a binary operator, and the comma seems like a workaround for arguments on a single line than good practice (at least in this case).

@asottile asottile changed the title W504 on PEP570 slash W504: positional only argument at end of long line Jul 14, 2020
@asottile
Copy link
Member

this also triggers with keyword-only arguments:

$ cat t.py 
def really_long_name_for_a_function(
    very_long_argument_1, very_long_argument_2, *
):
    pass
$ ~/opt/venv/bin/pycodestyle t.py --select=W503,W504
t.py:2:49: W504 line break after binary operator

@asottile asottile changed the title W504: positional only argument at end of long line W504: positional only / keyword only argument marker at end of long line Jul 14, 2020
@DevilXD
Copy link

DevilXD commented Apr 2, 2021

Just ran into this myself. Simple snippet for reproduction:

def func1(arg1, arg2, arg3, /):  # no error
    pass


def func2(
    arg1, arg2, arg3, /  # W504 line break after binary operator
):
    pass

@sigmavirus24
Copy link
Member

Thanks @DevilXD I think we already had enough examples for reproduction though and don't need further ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants