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

False positive: multiple-statements (C0321) should not trigger for stub functions #7860

Closed
GideonBear opened this issue Nov 28, 2022 · 10 comments · Fixed by #7863
Closed

False positive: multiple-statements (C0321) should not trigger for stub functions #7860

GideonBear opened this issue Nov 28, 2022 · 10 comments · Fixed by #7863
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@GideonBear
Copy link
Contributor

Bug description

For example:

class MyClass(ABC):
    @abstractmethod
    def function(self) -> int: ...  # this should not raise `multiple-statements` error as it's a stub

... is technically a statement, but shouldn't be considered one.

If accepted, I would be interested in submitting a PR for this.

Configuration

No response

Command used

N/A

Pylint output

C0321 More than one statement on a single line (multiple-statements)

Expected behavior

No error

Pylint version

pylint 2.16.0-dev
astroid 2.12.13
Python 3.9.15 (main, Nov 11 2022, 13:33:56) 
[GCC 9.4.0]

OS / Environment

No response

Additional dependencies

No response

@GideonBear GideonBear added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 28, 2022
@clavedeluna
Copy link
Contributor

I think the warning is correct as is. Same rational for raising the warning on if 1: return True, it's easier to read when ... is in a separate line.

Is there a PEP that says otherwise?

@clavedeluna clavedeluna added Needs decision 🔒 Needs a decision before implemention or rejection and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 28, 2022
@mbyrnepr2
Copy link
Member

Currently, functions decorated with typing.overload are permitted to have it on the same line; so there is precedent in pylint for this proposed change.

@GideonBear
Copy link
Contributor Author

Is there a PEP that says otherwise?

PEP 8 doesn't say it specifically, but in other recommendations it does put ... on the same line in some examples.

@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Nov 28, 2022

Are you importing abstractmethod from abc? I think it works already.

Update: Whoops ignore that 👓

@GideonBear
Copy link
Contributor Author

Are you importing abstractmethod from abc? I think it works already.

Not working both for @abstractmethod and @property + @abstractmethod

@GideonBear
Copy link
Contributor Author

It does work for Protocols though.

@mbyrnepr2
Copy link
Member

I think its common-enough to have this pattern on the same line; but let's wait a bit for more feedback from maintainers.

@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Nov 28, 2022

We could try a vote to make it easier:

🚀 for false-positive (we will remove the message when ellipsis is on the same line)
👀 Do nothing (ellipsis should be on the following line)

@GideonBear
Copy link
Contributor Author

It should be as easy as replacing this with return

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.0 milestone Nov 28, 2022
@mbyrnepr2
Copy link
Member

I think you are good to go @GideonBear 😀

@mbyrnepr2 mbyrnepr2 added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs decision 🔒 Needs a decision before implemention or rejection labels Nov 28, 2022
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.17.0, 2.15.8 Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants