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

FURB105 [*] Unnecessary separator passed to print #8078

Closed
SHEscher opened this issue Oct 19, 2023 · 3 comments · Fixed by #8079
Closed

FURB105 [*] Unnecessary separator passed to print #8078

SHEscher opened this issue Oct 19, 2023 · 3 comments · Fixed by #8079
Assignees
Labels
bug Something isn't working

Comments

@SHEscher
Copy link

Hi, there seems to be a mismatch:

# print each element of a list to a new line
print(*a_list_with_elements, sep="\n")
ruff . --select FURB105  --preview
# out: ... FURB105 [*] Unnecessary separator passed to `print`

However, FURB105 apparently checks for empty prints:

ruff rule FURB105
# out: Checks for `print` calls with an empty string as the only positional ...

Version ruff 0.1.1

@charliermarsh
Copy link
Member

This seems like a bug, since the separator is necessary here.

@SHEscher
Copy link
Author

For

print(*a_list_with_elements, sep=",")

it is the same behaviour.

Plus description of rule and application don't seem to match, since it is not an empty print()

@charliermarsh
Copy link
Member

Yeah the rule is slightly more expansive than the description suggests -- I've updated it. It also looks for print calls with one or fewer arguments that define a custom separator, since the separator is redundant in that case. I've also fixed the bug here related to starred arguments.

charliermarsh added a commit that referenced this issue Oct 19, 2023
…#8079)

Given `print(*a_list_with_elements, sep="\n")`, we can't remove the
separator (unlike in `print(a, sep="\n")`), since we don't know how many
arguments were provided.

Closes #8078.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants