hacking check for jsonutils produces pep8 traceback
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Low
|
Ihar Hrachyshka |
Bug Description
the new jsonutils hacking check produces a pep8 traceback because it returns a set (column offset and error text) instead of an iterable (as logical line checks, like this check, should).
commit 243879f5c51fc45
Change-Id: I86ed6cd3316dd4
===== 8< ===== TEST CASE ===== 8< =====
$ echo 'foo = json.dumps(bar)' >nova/foobar.py
$ flake8 -vv nova/foobar.py
local configuration: in /home/dev/
ignore = E121,E122,
exclude = .venv,.
checking nova/foobar.py
foo = json.dumps(bar)
Traceback (most recent call last):
File "/home/
load_
File "/home/
report = flake8_
File "/home/
runner(path)
File "/home/
return fchecker.
File "/home/
self.
File "/home/
for offset, text in self.run_
TypeError: 'int' object is not iterable
===== 8< ===== TEST CASE ===== 8< =====
diff --git a/nova/
index a1dd614..7fe7412 100644
--- a/nova/
+++ b/nova/
@@ -300,7 +300,7 @@ def use_jsonutils(
for f in json_funcs:
pos = logical_
if pos != -1:
- return (pos, msg % {'fun': f})
+ yield (pos, msg % {'fun': f})
def factory(register):
===== 8< ===== PATCH ===== 8< =====
it's late, so tomorrow, if there hasn't been any activity on this, then i'll submit a patch for review.
Changed in nova: | |
importance: | Undecided → Low |
Changed in nova: | |
milestone: | none → juno-3 |
status: | Fix Committed → Fix Released |
Changed in nova: | |
milestone: | juno-3 → 2014.2 |
flake8 output after patch applied:
===== 8< ===== OUTPUT ===== 8< ===== py:1:18: F821 undefined name 'bar'
$ echo 'foo = json.dumps(bar)' >nova/foobar.py
$ flake8 nova/foobar.py
nova/foobar.py:1:7: F821 undefined name 'json'
nova/foobar.py:1:7: N323 jsonutils.dump must be used instead of json.dump
nova/foobar.py:1:7: N323 jsonutils.dumps must be used instead of json.dumps
nova/foobar.
===== 8< ===== OUTPUT ===== 8< =====
ignore the F821 errors as they are a product of this merely being a single line example (ie i don't import the json module nor define the variable bar) and nothing more.