flake8
-
rbtools/commands/__init__.py (Diff revision 1) -
-
-
-
-
Review Request #11521 — Created March 20, 2021 and submitted
JSON wrapper class which inputs to a dictionary and outputs a JSON object. Class
is defined inrbtools/commands/__init__.py
Command class. New command--json
added to global options, which can be added to any command. When--json
is active
run_from_argv
will print the json object using Python's json library.For a full list of proposed JSON objects for each command see:
https://www.notion.so/reviewboard/a8cd6ee32806415fb7bba484d630863e?v=25fb1c9182064421ab17e55606da765b
Passed all tests in
Command
. Added new tests intest_main.py
for initializing
wrapper, adding key value pairs to dictionary, getting correct JSON string from
dictionary, and printing to output stream with correct JSON string.
Summary | ID |
---|---|
fc3442b40f7688eae2dc8943c3905de1189aba49 | |
93a7f52f930aec3fe39c3d0d9c0f15ee4a14922c | |
8d6ea988b098794628c133cbbcd42f524293d873 | |
312b2d649dc71fa01637c427209d5f972c193402 | |
9ecb2ddb435c1889c5b000d2ad2d57f7bc3f04b8 | |
99df72a53c52f7b839decff237fa694d19baa190 | |
505c93c8f2a525fc8a8114e37b69ccdf4f283b9d | |
1c4e3367bd82af470f4889056c35e1e137b9d9ff | |
c110d05aca25324d53b55ed678169610aa9a7c07 | |
d58d4e8f8bbe7b1c4486479d2d4ebc25cb545010 | |
29daf66756b65033e122b5cb2466e588ad4a7635 | |
a0ee53dabe7e1c7894412281719b38db1410f16f | |
40c9ab291084fd36bed86e74761ed579706a612c | |
fe0dd7c90d293e3885890f4ca3be0dafe506a63a | |
b662b573e9452277ea177d990b2f8d750028f2f2 | |
412f531a218f3c9bf2eac16ebb765ef74d0bcb30 | |
4225f35a6f49eb25af995c27b7cdbc1978a31edc | |
f7e7e1ae2398aaa2aec3e63dcad942edc72a8b3e |
Description | From | Last Updated |
---|---|---|
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
This class and all the methods inside need docstrings. Perhaps instead of "Wrapper" (it's not really wrapping anything), just call … |
david | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
Let's make the help be something like "Output results as JSON data instead of text" |
david | |
W293 blank line contains whitespace |
reviewbot | |
This comment isn't necessary--the code is pretty self explanatory. |
david | |
Looks like this still needs to be done. But initialize_scm_tool isn't the right place to do it. |
david | |
Let's do import kgb and inherit from kgb.SpyAgency |
david | |
These two lines can be combined: from rbtools.commands import JSONWrapper, main as rbt_main |
david | |
It might be worth defining a setUp method that sets self.json = JSONWrapper(sys.stdout). That way you don't have to do … |
david | |
E303 too many blank lines (2) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
W291 trailing whitespace |
reviewbot | |
W293 blank line contains whitespace |
reviewbot | |
I think it might be better to do self.json.add_error(str(e)) because most of the errors raised (ex. CommandError, ApiError) are not … |
amohapatra |
Commits: |
|
|||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+270 -12) |
rbtools/commands/__init__.py (Diff revision 2) |
---|
This class and all the methods inside need docstrings.
Perhaps instead of "Wrapper" (it's not really wrapping anything), just call it something like "JSONOutput"?
rbtools/commands/__init__.py (Diff revision 2) |
---|
Let's make the help be something like "Output results as JSON data instead of text"
rbtools/commands/__init__.py (Diff revision 2) |
---|
This comment isn't necessary--the code is pretty self explanatory.
rbtools/commands/__init__.py (Diff revision 2) |
---|
Looks like this still needs to be done. But
initialize_scm_tool
isn't the right place to do it.
rbtools/commands/tests/test_main.py (Diff revision 2) |
---|
Let's do
import kgb
and inherit fromkgb.SpyAgency
rbtools/commands/tests/test_main.py (Diff revision 2) |
---|
These two lines can be combined:
from rbtools.commands import JSONWrapper, main as rbt_main
rbtools/commands/tests/test_main.py (Diff revision 2) |
---|
It might be worth defining a
setUp
method that setsself.json = JSONWrapper(sys.stdout)
. That way you don't have to do it individually in each test.
Commits: |
|
|||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+279 -21) |
Commits: |
|
|||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+363 -65) |
rbtools/commands/tests/test_main.py (Diff revision 4) |
---|
E127 continuation line over-indented for visual indent
Commits: |
|
|||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+370 -68) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 6 (+441 -79) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 7 (+456 -98) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 8 (+466 -98) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 9 (+467 -99) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 10 (+468 -100) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 11 (+470 -100) |
rbtools/commands/__init__.py (Diff revision 11) |
---|
I think it might be better to do self.json.add_error(str(e)) because most of the errors raised (ex. CommandError, ApiError) are not JSON serializable.
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 12 (+471 -103) |
Commits: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 13 (+472 -104) |
Description: |
|
---|