Warn that setattr(<identifier>, <string literal>, ...) should be an assignment

Bug #1386424 reported by Michael Schurter
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
Confirmed
Undecided
Unassigned

Bug Description

setattr(<identifier>, <string literal>, ...) can always be rewritten as a simple assignment. Would make a nice warning.

Revision history for this message
Ian Cordasco (icordasc) wrote :

Note this is only in cases like: setattr(self, 'some_attribute', val). If the second argument isn't a string literal, there would be no warning.

Changed in pyflakes:
status: New → Confirmed
Revision history for this message
Phil Frost (bitglue) wrote :

Pyflakes has no concept of "warnings". It only has errors, and Pyflakes on principle emits errors only about things it is sure are errors. This is a useful property that similar tools do not have: you can run Pyflakes on any codebase, and it shouldn't spew any errors unless there are really errors in the program.

flake8 adds pep8 checking to pyflakes, which is a good option if you like pyflakes but want checks that are predicated on style and opinion. pylint and pychecker are unrelated to pyflakes, but also do style-based checks. You might evaluate those tools to see if they better suit your needs.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.