flake8
-
rbtools/commands/__init__.py (Diff revision 1) Show all issues -
-
-
-
-
Review Request #11521 — Created March 20, 2021 and submitted
Information | |
---|---|
ryankang | |
RBTools | |
master | |
|
|
11572, 11541, 11588, 11560, 11589, 11590, 11591, 11573 | |
Reviewers | |
rbtools, students | |
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 | |
---|---|
Description | From | Last Updated |
---|---|---|
W293 blank line contains whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
E303 too many blank lines (2) |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
E501 line too long (80 > 79 characters) |
![]() |
|
This class and all the methods inside need docstrings. Perhaps instead of "Wrapper" (it's not really wrapping anything), just call … |
|
|
W293 blank line contains whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
Let's make the help be something like "Output results as JSON data instead of text" |
|
|
W293 blank line contains whitespace |
![]() |
|
This comment isn't necessary--the code is pretty self explanatory. |
|
|
Looks like this still needs to be done. But initialize_scm_tool isn't the right place to do it. |
|
|
Let's do import kgb and inherit from kgb.SpyAgency |
|
|
These two lines can be combined: from rbtools.commands import JSONWrapper, main as rbt_main |
|
|
It might be worth defining a setUp method that sets self.json = JSONWrapper(sys.stdout). That way you don't have to do … |
|
|
E303 too many blank lines (2) |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
E501 line too long (80 > 79 characters) |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
W291 trailing whitespace |
![]() |
|
E127 continuation line over-indented for visual indent |
![]() |
|
E501 line too long (83 > 79 characters) |
![]() |
|
W291 trailing whitespace |
![]() |
|
W291 trailing whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
W291 trailing whitespace |
![]() |
|
W293 blank line contains whitespace |
![]() |
|
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 … |
|
rbtools/commands/__init__.py (Diff revision 1) |
---|
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: |
|
---|