flake8
-
reviewboard/reviews/managers.py (Diff revision 1) Show all issues -
reviewboard/reviews/managers.py (Diff revision 1) F841 local variable 'query' is assigned to but never used
Review Request #12339 — Created June 4, 2022 and submitted
This is a basic cleanup change that improves the readability of several
of the larger query-building functions in our model managers. This
mainly centers around:
Consistent naming (
q
vs.queryset
instead ofquery
being used
for either orqs
sometimes being used).
|=
and&=
instead ofq = q |
orq = q &
.Doing as much with
Q()
objects as possible before calling methods
likefilter(...)
.Starting with a
Q()
object before any conditional logic, instead of
starting fresh inside of conditionals, to avoid potential issues with
logic being overridden unintentionally.General formatting improvements to help readability of some logic
when combiningQ()
objects.Using our modern chaining-like formatting for multi-line queryset
conditionals (chainingfilter()
andorder_by()
across lines, for
instance).This helps ensure more consistent code going forward, and lays a
foundation for some query optimization work that is coming.
All unit tests pass.
reviewboard/reviews/managers.py (Diff revision 1) |
---|
reviewboard/reviews/managers.py (Diff revision 1) |
---|
F841 local variable 'query' is assigned to but never used
Added a missing unstaged line.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+184 -184) |
Removed a now-redundant
q = Q()
.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+184 -188) |