-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Restapi refactor #2890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restapi refactor #2890
Conversation
This is a first step and only adds docstrings, etc. It doesn't refactor any code.
ad0578b
to
de4ffb1
Compare
In several cases, we can use the provided `request` rather than access `self` (which could make these functions easier to test in isolation). In others, the unused args could be folded into an unnamed kwarg param.
Smaller functions should be easier to test independently. This will also resolve a pyflakes warning.
This worked as intended, but only because the overridden section variable would later evaluate to True. Using a different variable name makes this a bit less error-prone.
By splitting the function up, we not only resolve pyflakes issues around local variables, we also make this function easier to test. I don't like the SectionIndexer approach, but there was a chunk of state (section_index_list) which was extended in each loop iteration. To recreate that functionality while limiting the number of lines in each loop, the state is moved into a separate object. If the original logic was faulty, this could be much more legible.
de4ffb1
to
c955155
Compare
Okay, so i've cherry-picked the linting changes in #2938 and got that merged, so lets view this as a refactor only PR -- could you rebase, or perhaps it's easier to even just create a new branch? Whatever works. The refactor here was slowing this PR down and I think there might need to be some more back and forth before the refactor gets merged. Some of the patterns in the refactor could be reduced or more generalized, so I'd like to find a good balance there. |
This includes some simple tweaks in addition to slightly more significant refactors to split up some functions. Easiest to review changeset by changeset.