W504: positional only / keyword only argument marker at end of long line
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce W504 with the positional-only argument example and compare it with the comma workaround. Trace the W504 handling in the repository's single Python file, then verify that the slash is no longer treated as a binary operator while genuine line breaks after binary operators still report W504.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100