Reduce too-many-branches across piccolo codebase#1398
Open
waniasantos wants to merge 13 commits into
Open
Conversation
…lper methods (R0912)
…ault to reduce branches (R0912)
Member
|
Thanks for this. It looks like one test failed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors 6 occurrences of Pylint's
too-many-branches(R0912) by extracting cohesive blocks of conditional logic into smaller, well-named auxiliary methods. Consistent pattern applied across the codebase: large functions broken down by responsibility (engine-specific SQL handling, M2M result processing, clause building, column introspection), with no changes to existing business logic.Refactored functions/methods
Table.__init_subclass__(table.py)Query._process_results(query/base.py)Select.response_handler(query/methods/select.py)Select.default_querystrings(query/methods/select.py)Column.get_sql_value(columns/base.py)create_table_class_from_db/get_column_default(apps/schema/commands/generate.py)Validation
pytest) passes after each refactorNotes
get_column_defaultin generate.py was additionally refactored from a longif/elifchain into a dispatch table (dict), which more cleanly eliminates the branch count without adding auxiliary methodsSelect.response_handlerandQuery._process_resultsfollow the same naming convention established in previous refactors on this branch, keeping the split consistent across the query layer