Add extra output when checking review request statuses.
Review Request #7640 — Created Sept. 18, 2015 and submitted
Originally, rbt status would only show the review request summary and the review request id.
The change will give the status of each review request, showing how many 'Open Issues' there are or how many 'Ship It!' there are. If there are no open issues, and the review request hasn't been submitted, it shows the 'Ship It!' count
Below is an example output:
(rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$ rbt status =========================================================================== Status Review Request =========================================================================== Open Issues (2) r/5 - Integer a amet Aliquam pharetra dui Draft r/6 - Quisque adipiscing tortor, amet velit orci Ship It! (1) r/3 - adipiscing congue ac fames non, posuere Pending r/7 - ipsum id. mi dui, Integer laoreet Pending r/4 - magna In aliquet tincidunt egestas Suspendisse (rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$
Ran rbt status to get the above output.
Ran rbt tests.
Description | From | Last Updated |
---|---|---|
For the arguments that get passed to the max method, I think that it would be more Pythonic if we … |
AD adriano | |
Needs a docstring. Docstrings should be of the form """Single line summary. Multi-line description. """ |
brennie | |
Since you are passing a generator, you only need one set of parenthesis. |
brennie | |
Style nitpick: blank line between these. |
brennie | |
Col: 35 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 33 E703 statement ends with a semicolon |
reviewbot | |
This should be written in the imperative mood (something like "Print review request statuses in a table"). |
david | |
Python str has a nifty ljust method, which can simplify this quite a bit: white_space = max_status_length + TAB_SIZE for … |
david | |
Docstrings should have a summary that fits entirely on one line and then a longer description (if necessary). They should … |
david | |
These should use single quotes. |
david | |
We should only say "Ship It" if there are one or more "Ship It" reviews. By default we should probably … |
david | |
It might be better to calculate this in the tabulate method, or to calculate all the lengths here. It's also … |
david | |
These could be formatted more nicely by being a bit less verbose and wrapping differently: max_status_length = max(d['status_len'] for d … |
david | |
Instead of using end='', let's just print both of these at the same time: print('%s%s' % ('Status'.ljust(white_space), 'Review Request')) |
david | |
Can you document the arguments to this function? We document our args as follows: """... Args: arg_name (arg_type): Description of … |
brennie | |
Can you comment on what these do? |
brennie | |
Can you format this like: status = request['status'].ljust(white_space) print('%s%s' % (status, request['summary']) |
brennie | |
You don't need the quotes here. print() should work. |
brennie | |
Can you document the args and return of the function as follows: ``` """... Args: arg_name (arg_type): Description of Arg … |
brennie | |
"Return" and not "Get". "Get" implies that we are querying for informatino. |
brennie | |
Blank line between these. Also, data is really generic. |
brennie | |
data is very generic. Can we call this something else? Perhaps request_stats? |
brennie | |
Can you put the comment directly before each one, e.g. # The number of spaces between a request status ... … |
brennie |
-
-
For the arguments that get passed to the
max
method, I think that it would be more Pythonic if we replaced the list comprehensions with generator expressions (that is, we can simply drop the outermost square brackets). That way, we aren't allocating memory for an intermediate list; instead, each integer is being generated on the fly. You might find this article useful: Code Like a Pythonista: Idiomatic Python
-
Tool: Pyflakes Processed Files: rbtools/commands/status.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py
-
I like the output, but it may be too much if you have a lot of review requests. Currently, they only take up one line each so its easy to get a summary at a glance. I think it would be better if it were formatted like:
============================================= Status Review Request ============================================= Draft r/1234 - Some Review Request Ship it! r/1235 - Some Review Request Open Issues (4) r/1236 - Some Review Request
-
Needs a docstring. Docstrings should be of the form
"""Single line summary. Multi-line description. """
-
-
- Description:
-
Originally, rbt status would only show the review request summary and the review request id.
~ The change adds the following additional information to each review request: approval status/reason, ship-it count, and open issue count.
~ The change will give the status of each review request, showing how many 'Open Issues' there are or how many 'Ship It!' there are. If there are no open issues, and the review request hasn't been submitted, it shows the 'Ship It!' count
Below is an example output:
(rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$ rbt status
~ =========================================================================
~ r/7619 - Ensure SSH is given a valid port number.
~ =========================================================================
~ Approved False
~ Reason The review request has not been marked "Ship It!"
~ Ship it Count 0
~ Open Issue Count 0
~ =========================================================================
~ =====================================================================
~ Status Review Request
~ =====================================================================
~ Open Issues (2) r/5 - Integer a amet Aliquam pharetra dui
~ Draft r/6 - Quisque adipiscing tortor, amet velit orci
~ Ship It! (1) r/3 - adipiscing congue ac fames non, posuere
~ Ship It! (0) r/7 - ipsum id. mi dui, Integer laoreet
~ Ship It! (0) r/4 - magna In aliquet tincidunt egestas Suspendisse
(rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$
- Diff:
-
Revision 3 (+52 -10)
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py Tool: Pyflakes Processed Files: rbtools/commands/status.py
-
-
This should be written in the imperative mood (something like "Print review request statuses in a table").
-
Python
str
has a niftyljust
method, which can simplify this quite a bit:white_space = max_status_length + TAB_SIZE for row in data: print '%s%s' % (row[0].ljust(white_space), row[1])
You can use it above for the header, too.
-
Docstrings should have a summary that fits entirely on one line and then a longer description (if necessary). They should also be written in the imperative mood (So "Get the current status" rather than "Gets ...").
-
-
We should only say "Ship It" if there are one or more "Ship It" reviews. By default we should probably just say something like "Pending" or "Open".
-
It might be better to calculate this in the tabulate method, or to calculate all the lengths here.
It's also not great to stuff a bunch of stuff into a list like this. It means that people reading the
tabulate
method have to then go read this method to figure out what's in the list. Perhaps use a dictionary instead?detail = 'r/%s - %s' % (request.id, request.summary) review_data.append({ 'status': status, 'detail': detail, 'status_len': len(status), 'detail_len': len(detail), 'row_len': len(status) + len(detail), })
-
Tool: Pyflakes Processed Files: rbtools/commands/status.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py
-
-
These could be formatted more nicely by being a bit less verbose and wrapping differently:
max_status_length = max(d['status_len'] for d in data) max_row_length = (max(d['summary_len'] for d in data) + PADDING + TAB_SIZE + max_status_length)
-
Instead of using
end=''
, let's just print both of these at the same time:print('%s%s' % ('Status'.ljust(white_space), 'Review Request'))
-
Tool: Pyflakes Processed Files: rbtools/commands/status.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py
-
Can you update the example output in the description?
Also, in your summary, the plural of "status" is "statuses" (possesive would use status')
- Summary:
-
Add extra output when checking review request status'.Add extra output when checking review request statuses.
- Description:
-
Originally, rbt status would only show the review request summary and the review request id.
The change will give the status of each review request, showing how many 'Open Issues' there are or how many 'Ship It!' there are. If there are no open issues, and the review request hasn't been submitted, it shows the 'Ship It!' count
Below is an example output:
(rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$ rbt status
~ =====================================================================
~ ===========================================================================
Status Review Request
~ =====================================================================
~ ===========================================================================
Open Issues (2) r/5 - Integer a amet Aliquam pharetra dui
Draft r/6 - Quisque adipiscing tortor, amet velit orci
Ship It! (1) r/3 - adipiscing congue ac fames non, posuere
~ Ship It! (0) r/7 - ipsum id. mi dui, Integer laoreet
~ Ship It! (0) r/4 - magna In aliquet tincidunt egestas Suspendisse
~ Pending r/7 - ipsum id. mi dui, Integer laoreet
~ Pending r/4 - magna In aliquet tincidunt egestas Suspendisse
(rbenv)vagrant@precise64:/src/reviewboard-2.0.x/reviewboard$
-
-
Can you document the arguments to this function?
We document our args as follows:
"""... Args: arg_name (arg_type): Description of arg. """
You don't need to document
self
. -
-
Can you format this like:
status = request['status'].ljust(white_space) print('%s%s' % (status, request['summary'])
-
-
Can you document the args and return of the function as follows:
```
"""...Args:
arg_name (arg_type):
Description of ArgReturns:
return_type: Description of return value
""" -
-
-
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/status.py Tool: Pyflakes Processed Files: rbtools/commands/status.py
-
-
Can you put the comment directly before each one, e.g.
# The number of spaces between a request status ... TAB_SIZE = 3 # THe number of ... PADDING = 5
These should also probably be class constants, e.g.
class Status(Command): # ... # The number of spaces... TAB_SIZE = 3
and you can refer to them with either
Status.TAB_SIZE
orself.TAB_SIZE
.