Skip to content

Unassigned instantiated classes should trigger a pointless-statement or a new message to be determined #3110

Closed
@vapier

Description

@vapier

Current status

pylint will issue pointless-statement when a class (e.g. Exception) is used. this is great:

$ cat test.py
Exception
$ pylint3 test.py
test.py:1:0: W0104: Statement seems to have no effect (pointless-statement)

but if the exception is instantiated, it's not shown:

$ cat test.py
Exception()
$ pylint3 test.py
<nothing>

Proposal

while instantiating random classes can have side-effects, exceptions rarely (if ever) have such behavior. it's so uncommon that, imo, it should trigger a warning by default. we ran into issues where people forgot to raise the exception (because the naming made it sound like it would throw an error), so code that was supposed to fail ended up not.

so how about:

$ cat test.py
Exception()
$ pylint3 test.py
test.py:1:0: W0104: Instantiated object seems to have no effect (pointless-exception-object)

feel free to bikeshed the exact naming/phrasing.

Version info

$ pylint3 --version
pylint3 2.2.2
astroid 2.1.0
Python 3.6.8 (default, Jan  3 2019, 03:42:36) 
[GCC 8.2.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    CheckersRelated to a checkerEnhancement ✨Improvement to a componentGood first issueFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions