String formatting warning on things that aren't string formatting
Bug #1165416 reported by
Jonathan Jacobs
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
twistedchecker |
In Progress
|
Undecided
|
Unassigned |
Bug Description
Code such as "5 % 2" produces the warning: "String formatting operations should always use a tuplefor non-mapping values."
Obviously this isn't a string. (Also "tuplefor" seems to be a typo in the message.)
Related branches
lp:~hawkowl/twistedchecker/string-formatting-1165416
Ready for review
for merging
into
lp:~twisted-dev/twistedchecker/trunk
- Richard Wall (community): Needs Fixing
- Twisted-dev: Pending requested
-
Diff: 55 lines (+22/-1)2 files modifiedtwistedchecker/checkers/formattingoperation.py (+18/-1)
twistedchecker/functionaltests/formattingoperation.py (+4/-0)
Changed in twistedchecker: | |
status: | New → Confirmed |
Changed in twistedchecker: | |
status: | Confirmed → In Progress |
To post a comment you must log in.
Okay so, I've done some investigating here.
I'm about to submit a branch that will fix this, maybe a little bit naively. It parses the left side (in that example, 5) and sees if it can parse it as an int or a float. If it can, it deems it a modulo operation. If the left side is a variable, then without actually knowing what that variable is at run time, it might still be a warning - in which case, people can just ignore it.