Reduce too-many-statements across piccolo codebase#1397
Open
waniasantos wants to merge 6 commits into
Open
Conversation
…duce __init_subclass__ statements and branches
…create_table_class_from_db to reduce statements and branches (R0915/R0912)
…duce statements and branches (R0915/R0912)
…dispatch pattern to reduce statements and branches (R0915/R0912)
…ault_querystrings to reduce statements and branches (R0915/R0912)
…reate_pydantic_model to reduce statements and branches (R0915/R0912)
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-statements(R0915) by extracting cohesive blocks of logic into smaller, well-named auxiliary functions/methods. Consistent pattern applied across the codebase: large functions broken down by responsibility (column collection, foreign key resolution, type-specific handlers, query building), with no changes to existing business logic.Refactored functions/methods
Table.__init_subclass__(table.py)create_table_class_from_db(apps/schema/commands/generate.py)MigrationManager._run_alter_columns(apps/migrations/auto/migration_manager.py)serialise_params(apps/migrations/auto/serialisation.py)Select.default_querystrings(query/methods/select.py)create_pydantic_model(utils/pydantic.py)Validation
pytest) passes after each refactorNotes
too-many-branches(R0912) violations on the same function/method, since the extracted logic contained most of the conditional branchingTable.__init_subclass__refactor, severalTableMetamethods were accidentally moved into the wrong nested class, causing anAttributeError. This was identified by running the full test suite and corrected before committing.