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

Missing trailing comma after multiplication reported as C815 #64

Open
cebtenzzre opened this issue Jan 22, 2021 · 1 comment
Open

Missing trailing comma after multiplication reported as C815 #64

cebtenzzre opened this issue Jan 22, 2021 · 1 comment

Comments

@cebtenzzre
Copy link

If a function argument contains multiplication, a C815 error ("... in Python 3.5+") is reported instead of C812, as if the expression includes tuple unpacking. This is misleading, because even Python 2.7 supports a trailing comma after multiplication.

Example Code

def foo(x): pass

foo(
    1
)
foo(
    *(1,)
)
foo(
    2 * 1
)

Actual Behavior

$ flake8 --select=C812,C815 repr.py
repr.py:4:6: C812 missing trailing comma
repr.py:7:10: C815 missing trailing comma in Python 3.5+
repr.py:10:10: C815 missing trailing comma in Python 3.5+

Expected Behavior

I would expect the error reported for line 10 to be C812, not C815.

Software Versions

Python 3.9
flake8-commas 2.0.0

@PeterJCLaw
Copy link
Contributor

Having a very quick look, this isn't immediately trivial to fix. The internal processing of tokens is done essentially one token at a time, whereas determining whether a token is a unpack token versus a multiplication (or an exponentiation) would require inspecting adjacent tokens.

This doesn't mean it's impossible to fix, however it does make it harder to fix and thus less appealing for what appears at this point to be a mostly cosmetic issue (given how far beyond EOL both Python 2 and 3.5 are).

I therefore don't have any immediate plans to fix this.

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

No branches or pull requests

2 participants